
Dan Franklin - 2009-01-16 15:59:55
We're starting to internationalize one of our websites, so I was very interested in this class when it appeared. I think there is a problem with the detectLanguage function. The line
$this->language = substr($this->languages,0,2);
appears to assume that all language codes are 2 characters long. In fact some language codes can be 3 characters long. See BCP47 ( http://www.rfc-editor.org/rfc/bcp/bcp47.txt ).
This assumption may be in other parts of this function as well - I see other "2"s in there.
It would be better to take the first string up to a '-' (or for some weird browsers, a '_' as well) to choose the language.
Thanks for providing the class!
Dan