Today I examined how Elgg supports foreign languages for web site internationalization. I discovered that Elgg does not check the browser’s language setting. Instead you have to set the language for the entire site. This means that you cannot create a social networking site which supports two languages.
Then I explored how PHP supports localization. You can set the locale using the method setlocal(LC_ALL, ‘fr-FR’); This allows you to display dates in the French format. It will also format numbers using French notation. French notation usually uses two decimals, comma (‘,’) as decimal separator, and space (‘ ‘) as thousand separator. To format currency you need to use the money_format method which is not supported on Windows. But I found some code for a method which does the same time. To get the time in Paris you need to set the time zone TZ to Europe/Paris.
After that I studied language settings in various browsers. There are really two settings you need to change. The language preference merely indicates which language you prefer to use for viewing content. It is up to the web site to detect this setting and redirect you to web pages in that language or dynamically generate HTML with strings in that language. I discovered that very few web sites bother to do this. Google, Microsoft, and Facebook will honor your browser language settings and display in French.
However, changing the browser language setting will not change the language indicated in the user agent string. I found that only Firefox and Opera really allow you to change that. I had considerable trouble getting Internet Explorer and Safari to use French rather than English so I gave up. In Firefox you need to enter about:config in the address bar and press Enter. Then enter general.useragent.locale in the Filter textbox and change en-US to fr-FR. The User Agent string will then indicate that the browser language is fr-FR:
Mozilla/5.0 (Windows; U; Windows NT 5.1; fr-FR; rv:18.104.22.168) Gecko/2009011913 Firefox/3.0.6 (.NET CLR 3.5.30729)
Opera also lets you change the preferred language for web pages but to go a step further you need to download the ouw960_fr.lng file and copy it to the C:\Program Files\Opera directory. This will change the entire user interface to French and the user agent will become:
Opera/9.63 (Windows NT 5.1; U; fr) Presto/2.1.1
Tomorrow I will learn how the web server and server side scripting can use the Accept–Language request-header to deliver content based on the browser language settings.