I have just recently installed the silverstripe Translatable to handle a multilingual site for us. I think i have set everything up correctly but cannot be sure. Maybe i'm missing something or maybe i misunderstand the module.
In my site _config.php i have the following
i18n::set_locale('en_US');
i18n::set_locale('fr_FR');
Translatable::set_default_locale('en_US');
SiteTree::add_extension('Translatable');
SiteConfig::add_extension('Translatable');
I have gone thru and created a translation of our home page. I can navigate to the translated page no problem. I can also verify that both the home page and the translation realize they are linked with the following code in Page.ss
<% if Translations %>
<% loop Translations %>
$Locale.RFC1766
$Link
<% end_loop %>
<% end_if %>
I also added lang="$ContentLocale" xml:lang="$ContentLocale" xmlns= "http://www.w3.org/1999/xhtml">
As expected on the french verison of the home page the US version shows and vice-versa. However when I access the site from a french computer with a french browser it goes straight to the english page. I would have thought that this would be handled automatically by either i18n part of silverstripe or by translatable. Do i need to handle this myself or am I missing something?
Answer based on Barry's Answer I ended up with the following lines of code in my _config.php
$lang = $_SERVER['HTTP_ACCEPT_LANGUAGE']; //Get the languag from the client
$lang = substr($lang,0,strpos($lang,','));//Strip out the unnecesary stuff after the comma
$lang = str_replace("-","_",$lang);//Replace the hyphen with an underscore.
Translatable::set_default_locale($lang);//Set locale