The change in commit 92b276c is wrong because it reverses the previous change to obey the RFC 2616 algorithm. Specifically RFC 2616 says that a request for en-GB will only match with en-GB or something that starts with en-GB and it will not match against en with no suffix. The test failures were because the test was wrong, not because the code was wrong. This commit restores the previous code and fixes the tests.
To work properly with Rails 3, HttpAcceptLanguage to be included to ActionDispatch::Request.
E.g. the example given under http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 has a space after the comma
We need to look for the longest matching prefix rather than just the first language with the same basic language code, otherwise if we have both zh-CN and zh-TW available then we may select the wrong one as we will return he first one we see that starts with zh even if the user had said they preferred a specific variant.
The code at http://zargony.com/2009/01/09/selecting-the-locale-for-a-request collects the available translations from config/locales and stores them as symbols, which I think is perfectly reasonable. The changes here allow the two to work together. Signed-off-by: Iain Hecker <email@example.com>
Signed-off-by: Iain Hecker <firstname.lastname@example.org>