[Zope-Checkins] SVN: Products.Five/branches/1.3/ Made sure LocalizerLanguages class normalized language codes to xx-yy.

Lennart Regebro regebro at gmail.com
Mon Apr 10 11:21:47 EDT 2006


Log message for revision 66790:
  Made sure LocalizerLanguages class normalized language codes to xx-yy.
  

Changed:
  U   Products.Five/branches/1.3/CHANGES.txt
  U   Products.Five/branches/1.3/i18n.py

-=-
Modified: Products.Five/branches/1.3/CHANGES.txt
===================================================================
--- Products.Five/branches/1.3/CHANGES.txt	2006-04-10 15:14:43 UTC (rev 66789)
+++ Products.Five/branches/1.3/CHANGES.txt	2006-04-10 15:21:47 UTC (rev 66790)
@@ -2,6 +2,12 @@
 Five Changes
 ============
 
+Five 1.3.5 (unreleased)
+=======================
+
+* Made sure LocalizerLanguages class normalized language codes to xx-yy, instead of
+  xx_YY or xx-YY.
+
 Five 1.3.4 (2006-03-31)
 =======================
 

Modified: Products.Five/branches/1.3/i18n.py
===================================================================
--- Products.Five/branches/1.3/i18n.py	2006-04-10 15:14:43 UTC (rev 66789)
+++ Products.Five/branches/1.3/i18n.py	2006-04-10 15:21:47 UTC (rev 66790)
@@ -19,6 +19,7 @@
 from zope.interface import implements
 from zope.i18n import interpolate
 from zope.i18n.interfaces import ITranslationDomain, IUserPreferredLanguages
+from zope.i18n.negotiator import normalize_lang
 from zope.app import zapi
 from zope.publisher.browser import BrowserLanguages
 
@@ -71,7 +72,9 @@
         accept_language = self.context.AcceptLanguage
         langs = []
         for lang, node in accept_language.children.items():
-            langs.append((node.get_quality(), lang))
+            # Localizer may use xx_YY and xx-YY as language codes,
+            # while Zope expect xx-yy only, so we normalize the code here.
+            langs.append((node.get_quality(), normalize_lang(lang)))
             langs.extend([(n.get_quality(), l) for l, n
                           in node.children.items()])
         langs.sort()



More information about the Zope-Checkins mailing list