"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "roundup/i18n.py" between
roundup-1.6.1.tar.gz and roundup-2.0.0.tar.gz

About: Roundup is an highly customisable issue-tracking system with command-line, web and e-mail interfaces (written in Python).

i18n.py  (roundup-1.6.1):i18n.py  (roundup-2.0.0)
skipping to change at line 38 skipping to change at line 38
(which can easily happen if a sentence has to be re-ordered due to (which can easily happen if a sentence has to be re-ordered due to
grammatical changes), translatable formats should use named format specs:: grammatical changes), translatable formats should use named format specs::
... _('Index of %(classname)s') % {'classname': cn} ... ... _('Index of %(classname)s') % {'classname': cn} ...
Also, this eases the job of translators since they have some context what Also, this eases the job of translators since they have some context what
the dynamic portion of a message really means. the dynamic portion of a message really means.
""" """
__docformat__ = 'restructuredtext' __docformat__ = 'restructuredtext'
import errno
import gettext as gettext_module import gettext as gettext_module
import os import os
from roundup import msgfmt from roundup import msgfmt
from roundup.anypy.strings import is_us
# List of directories for mo file search (see SF bug 1219689) # List of directories for mo file search (see SF bug 1219689)
LOCALE_DIRS = [ LOCALE_DIRS = [
gettext_module._default_localedir, gettext_module._default_localedir,
] ]
# compute mo location relative to roundup installation directory # compute mo location relative to roundup installation directory
# (prefix/lib/python/site-packages/roundup/msgfmt.py on posix systems, # (prefix/lib/python/site-packages/roundup/msgfmt.py on posix systems,
# prefix/lib/site-packages/roundup/msgfmt.py on windows). # prefix/lib/site-packages/roundup/msgfmt.py on windows).
# locale root is prefix/share/locale. # locale root is prefix/share/locale.
if os.name == "nt": if os.name == "nt":
skipping to change at line 82 skipping to change at line 82
""" """
# body of this function is borrowed from gettext_module.find() # body of this function is borrowed from gettext_module.find()
if language is None: if language is None:
languages = [] languages = []
for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'): for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'):
val = os.environ.get(envar) val = os.environ.get(envar)
if val: if val:
languages = val.split(':') languages = val.split(':')
break break
elif isinstance(language, str) or isinstance(language, unicode): elif is_us(language):
languages = [language] languages = [language]
else: else:
# 'language' must be iterable # 'language' must be iterable
languages = language languages = language
# now normalize and expand the languages # now normalize and expand the languages
nelangs = [] nelangs = []
for lang in languages: for lang in languages:
for nelang in gettext_module._expand_lang(lang): for nelang in gettext_module._expand_lang(lang):
if nelang not in nelangs: if nelang not in nelangs:
nelangs.append(nelang) nelangs.append(nelang)
skipping to change at line 139 skipping to change at line 139
else: else:
motime = 0 motime = 0
pofile = basename + ".po" pofile = basename + ".po"
if os.path.isfile(pofile): if os.path.isfile(pofile):
potime = os.path.getmtime(pofile) potime = os.path.getmtime(pofile)
else: else:
potime = 0 potime = 0
# see what we've found # see what we've found
if motime < potime: if motime < potime:
# compile # compile
msgfmt.make(pofile, mofile) mo = msgfmt.Msgfmt(pofile).get()
open(mofile, 'wb').write(mo)
elif motime == 0: elif motime == 0:
# no files found - proceed to the next locale name # no files found - proceed to the next locale name
continue continue
# .mo file found or made # .mo file found or made
return mofile return mofile
return None return None
def get_translation(language=None, tracker_home=None, def get_translation(language=None, tracker_home=None,
translation_class=RoundupTranslations, translation_class=RoundupTranslations,
null_translation_class=RoundupNullTranslations null_translation_class=RoundupNullTranslations):
):
"""Return Translation object for given language and domain """Return Translation object for given language and domain
Argument 'language' may be a single language code or a list of codes. Argument 'language' may be a single language code or a list of codes.
If 'language' is omitted or None, use locale settings in OS environment. If 'language' is omitted or None, use locale settings in OS environment.
Arguments 'translation_class' and 'null_translation_class' Arguments 'translation_class' and 'null_translation_class'
specify the classes that are instantiated for existing specify the classes that are instantiated for existing
and non-existing translations, respectively. and non-existing translations, respectively.
""" """
skipping to change at line 205 skipping to change at line 205
# ignore unreadable .mo files # ignore unreadable .mo files
pass pass
if translator is None: if translator is None:
translator = null_translation_class() translator = null_translation_class()
return translator return translator
# static translations object # static translations object
translation = get_translation() translation = get_translation()
# static translation functions # static translation functions
_ = gettext = translation.gettext _ = gettext = translation.gettext
ugettext = translation.ugettext try:
# Python 2.
ugettext = translation.ugettext
except AttributeError:
# Python 3.
ugettext = translation.gettext
ngettext = translation.ngettext ngettext = translation.ngettext
ungettext = translation.ungettext try:
# Python 2.
ungettext = translation.ungettext
except AttributeError:
# Python 3.
ungettext = translation.ngettext
# vim: set filetype=python sts=4 sw=4 et si : # vim: set filetype=python sts=4 sw=4 et si :
 End of changes. 7 change blocks. 
8 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)