1. locale preference stored in session of the Web application
2. locale preference stored in user settings of the Web application
3. locale preference advertised in browser
3. a) Accept-Language header
3. b) language/territory in User-Agent header
3. c) IP address lookup/geoip
3. d) Geolocation API
4. default locale of the Web application
You will notice that Google tries to be "smarter", to the detraction of the user, as shown in many comments in this thread.
Implementation notes: 1. and 2. require a locale selection somewhere as part of the Web application, 3. is browser settings, 4. is hard coded in the Web application.
----
From the article:
> Don't set the language of your website based on user location
This is an extreme/absolute prohibition and therefore almost certainly false/useless. Done correctly, user location is one clue in a chain.
> why would I have my machine in that language? And if it's not, I will change it myself.
Sometimes, it is not possible or feasible. Be aware of these situations. Examples:
* You are in an internet cafe or corporate environment and the browser settings are locked down by admin policy.
* You borrow someone else's mobile phone or tablet for a few minutes.