[Zope3-checkins] CVS: Zope3/src/zope/i18n - negotiator.py:1.9

Sidnei da Silva sidnei at x3ng.com.br
Mon Mar 1 08:08:50 EST 2004


Update of /cvs-repository/Zope3/src/zope/i18n
In directory cvs.zope.org:/tmp/cvs-serv13200

Modified Files:
	negotiator.py 
Log Message:
Fallback to base language in case the specific variation is not available.


=== Zope3/src/zope/i18n/negotiator.py 1.8 => 1.9 ===
--- Zope3/src/zope/i18n/negotiator.py:1.8	Fri Feb 27 17:25:22 2004
+++ Zope3/src/zope/i18n/negotiator.py	Mon Mar  1 08:08:19 2004
@@ -47,6 +47,15 @@
         for lang in userlangs:
             if lang in langs:
                 return langs.get(lang)
+            # If the user asked for a specific
+            # variation, but we don't have it available
+            # we may serve the most generic one, according
+            # to the spec (eg: user asks for ('en-us', 'de'),
+            # but we don't have 'en-us', then 'en' is
+            # preffered to 'de').
+            parts = lang.split('-')
+            if len(parts) > 1 and parts[0] in langs:
+                return langs.get(parts[0])
         return None
 
 




More information about the Zope3-Checkins mailing list