How to make a site multilingual and identify the country of origin?

I am developing a site in JavaEE and would like it to be multilingual (at least English, Portuguese and Spanish). But I would like to know how large sites, such as Facebook, for example, do to identify the country of origin and offer the site in the language of that country.

I know that there are several ways to do this, through tables and queries in the database, with arrays, I have seen even through a copy of all files with their proper translations located in another server directory.

Dropbox, for example, uses Javascript.

I would like to know which of these forms is the one that least burdens the server (and if there are other forms?) and how can I do to identify what my visitor's language is. I would also like to know what is the best way for future maintenance and adjustments, disregarding performance.

Author: Avelino, 2014-08-31

1 answers

The user's preferred language is probably what is configured in the browser, which is usually the language (and locale) of the operating system.

You can check this language in the header Accept-Language that accompanies the request. An example of the value contained in this header is en-US,en;q=0.8,pt;q=0.6.

The first part, before the first , is the language tag. In this case en-US. This format is an IETF standard that you can read more by searching for " IETF language tags."

To test your website with different languages you can change the locale of your browser and/or operating system and refresh the page. The way to change the language / locale varies from browser to browser and OS to OS. In Google Chrome, for example, you can go to chrome://settings/languages and reorder/add languages.

 3
Author: sergiopereira, 2014-09-19 18:32:19