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

5

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

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

Dropbox, for example, uses Javascript .

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

    
asked by anonymous 31.08.2014 / 06:38

1 answer

3

The user's preferred language is probably what is set 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 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.

    
19.09.2014 / 20:32