I notice that TurboGears2 can't pick correct language automatically by
languages given by browser. For example, the acceptable languages
setting of my browser is [zh-tw, en-us, en]. I do provide zh_TW in my
i18n folder, it works fine if I set the language to zh_TW. But most of
browser write the language in zh-tw form, gettext can't recognize
that, so it just fallback to en. I wrote a workaround to fix problem:
# XXX work around for languages in dash form problem
# gettext can't recognize that form, for example, it can recognize
# 'zh_tw' rather than zh-tw, so we need to replace all dash to
# underscore to fix this problem
import tg.i18n
oldFunc = tg.i18n.set_temporary_lang
def newSetTemporaryLang(languages):
languages = map(lambda lang: lang.replace('-', '_'),
languages)
return oldFunc(languages)
tg.i18n.set_temporary_lang = newSetTemporaryLang
Posted here:
http://trac.turbogears.org/ticket/2406
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---