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.