#2406: Workaround for i18n bug
------------------------+---------------------------------------------------
 Reporter:  victorlin   |       Owner:                  
     Type:  defect      |      Status:  new             
 Priority:  normal      |   Milestone:  __unclassified__
Component:  TurboGears  |     Version:  2.0b7           
 Severity:  normal      |    Keywords:                  
------------------------+---------------------------------------------------
 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
 }}}

-- 
Ticket URL: <http://trac.turbogears.org/ticket/2406>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "TurboGears Tickets" group.
This group is read-only. No posting by normal members allowed.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to