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

Asked

Viewed 1,469 times

5

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 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 seen even through a copy of all files with its 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 ways?) and how can I identify which is my visitor’s language. I would also like to know what is the best way for future maintenance and adjustments, disregarding performance.

  • 1

    Note: This is not a duplicate of: http://answall.com/questions/21788/como-tornar-um-site-multil%C3%Adngue.

  • 1

    This question will end up showing up here too: http://i.stack.Imgur.com/qlgqy.png :) Note that the tag is automatically added to <title>.

1 answer

3


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

You can check this language in the header (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 that case en-US. This format is an IETF standard that you can read further by searching for "IETF language tags."

To test your site with different languages you can change the locale from your browser and/or operating system and refresh the page. How to change 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.

  • Can you say if there is a definition of ip s by country? I would like to translate my site into English whenever the access was made from an ip other than Brazil.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.