[Twisted-web] nevow/i18n.py - Suggested better client's language resolving

Paul Reznicek maillists at ivsn.com
Mon Jul 25 03:30:52 MDT 2005

If the user's browser has selected country-specific languages, like:
the default language will be not correctly resolved OR you should have
.../LC_MESSAGES for each variant, i.e. for German maintaining translations
( de/LC_MESSAGES, de-de/LC_., de-at/LC_., de-ch/LC_., de-li/LC_., de-lu/LC_... )

Following patch add to the language list automatically the base variant,
so that if i.e. "de-de" is not found, translation "de" with same quality
will be used.
--- i18n.py    (Revision 1672)
+++ i18n.py    (Arbeitskopie)
@@ -19,6 +19,8 @@
                  except ValueError:
          langs.append((quality, lang))
+        if '-' in lang:
+            langs.append((quality, lang.split('-')[0]))
      langs.sort(lambda a,b: cmp(b[0], a[0]))
      return [lang for quality, lang in langs]

More information about the Twisted-web mailing list