The preferredLocale() function did not always return locale in lower case. This may conflict with using other functions together, such as setLocaleFromQuery() and setLocaleFromCookie(). So I changed it to return always lower case.
Also, I removed unnecessary loops. When my web browser sent headers["accept-language"] == 'ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4', the while loop in the preferredLocale() function looped four times even the ko was matched on the first loop.
The
preferredLocale()
function did not always return locale in lower case. This may conflict with using other functions together, such assetLocaleFromQuery()
andsetLocaleFromCookie()
. So I changed it to return always lower case.Also, I removed unnecessary loops. When my web browser sent
headers["accept-language"] == 'ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4'
, the while loop in thepreferredLocale()
function looped four times even theko
was matched on the first loop.