Index: trac/l10n.py
===================================================================
--- trac/l10n.py	(revisión: 0)
+++ trac/l10n.py	(revisión: 0)
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2005 Sergio Talens-Oliag <sto@debian.org>
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.com/license.html.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://projects.edgewall.com/trac/.
+#
+# Author: Sergio Talens-Oliag <sto@debian.org>
+
+import gettext
+import locale
+import __builtin__
+
+# ----------------
+# Global variables
+# ----------------
+# Translations dictionary
+_translations = {}
+# Standard translation
+_stdtr = gettext.translation('trac', fallback=True)
+# Current langcode
+_clang = None
+
+# ---------
+# Functions
+# ---------
+def updateLocale():
+  global _clang, _stdtr, _translations
+  langcode = locale.getlocale(locale.LC_ALL)[0]
+  if langcode == _clang:
+    return
+  _clang = langcode
+  if langcode == None or langcode == "":
+    __builtin__.__dict__['_'] = _stdtr.gettext
+  else:
+    if langcode not in _translations:
+      _translations[langcode] = gettext.translation('trac', languages=[langcode], fallback=True)
+    __builtin__.__dict__['_'] = _translations[langcode].gettext
+
+# ------------------
+# First load actions
+# ------------------
+
+# Install default translations
+__builtin__.__dict__['_'] = _stdtr.gettext
+# Call updateLocale
+updateLocale()

