Edgewall Software

TracL10N: trac-0.9.0-20051108-l10n.py.patch

File trac-0.9.0-20051108-l10n.py.patch, 1.7 KB (added by sto@…, 7 years ago)

Patch that creates the trac/l10n.py file missing from trac-0.9.0-20051108-gettext_support.patch

  • trac/l10n.py

     
     1# -*- coding: utf-8 -*- 
     2# 
     3# Copyright (C) 2005 Sergio Talens-Oliag <sto@debian.org> 
     4# All rights reserved. 
     5# 
     6# This software is licensed as described in the file COPYING, which 
     7# you should have received as part of this distribution. The terms 
     8# are also available at http://trac.edgewall.com/license.html. 
     9# 
     10# This software consists of voluntary contributions made by many 
     11# individuals. For the exact contribution history, see the revision 
     12# history and logs, available at http://projects.edgewall.com/trac/. 
     13# 
     14# Author: Sergio Talens-Oliag <sto@debian.org> 
     15 
     16import gettext 
     17import locale 
     18import __builtin__ 
     19 
     20# ---------------- 
     21# Global variables 
     22# ---------------- 
     23# Translations dictionary 
     24_translations = {} 
     25# Standard translation 
     26_stdtr = gettext.translation('trac', fallback=True) 
     27# Current langcode 
     28_clang = None 
     29 
     30# --------- 
     31# Functions 
     32# --------- 
     33def updateLocale(): 
     34  global _clang, _stdtr, _translations 
     35  langcode = locale.getlocale(locale.LC_ALL)[0] 
     36  if langcode == _clang: 
     37    return 
     38  _clang = langcode 
     39  if langcode == None or langcode == "": 
     40    __builtin__.__dict__['_'] = _stdtr.gettext 
     41  else: 
     42    if langcode not in _translations: 
     43      _translations[langcode] = gettext.translation('trac', languages=[langcode], fallback=True) 
     44    __builtin__.__dict__['_'] = _translations[langcode].gettext 
     45 
     46# ------------------ 
     47# First load actions 
     48# ------------------ 
     49 
     50# Install default translations 
     51__builtin__.__dict__['_'] = _stdtr.gettext 
     52# Call updateLocale 
     53updateLocale()