Skip to content

Commit d8d46dd

Browse files
author
Alexander Smishlajev
committed
search mo files relative to roundup installation path [SF#1219689]
1 parent e90ee92 commit d8d46dd

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

roundup/i18n.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: i18n.py,v 1.14 2004-11-17 07:18:27 a1s Exp $
18+
# $Id: i18n.py,v 1.14.2.1 2005-06-22 06:34:01 a1s Exp $
1919

2020
"""
2121
RoundUp Internationalization (I18N)
@@ -43,6 +43,23 @@
4343

4444
from roundup import msgfmt
4545

46+
# List of directories for mo file search (see SF bug 1219689)
47+
LOCALE_DIRS = [
48+
gettext_module._default_localedir,
49+
]
50+
# compute mo location relative to roundup installation directory
51+
# (prefix/lib/python/site-packages/roundup/msgfmt.py on posix systems,
52+
# prefix/lib/site-packages/roundup/msgfmt.py on windows).
53+
# locale root is prefix/share/locale.
54+
if os.name == "nt":
55+
_mo_path = [".."] * 4 + ["share", "locale"]
56+
else:
57+
_mo_path = [".."] * 5 + ["share", "locale"]
58+
_mo_path = os.path.normpath(os.path.join(msgfmt.__file__, *_mo_path))
59+
if _mo_path not in LOCALE_DIRS:
60+
LOCALE_DIRS.append(_mo_path)
61+
del _mo_path
62+
4663
# Roundup text domain
4764
DOMAIN = "roundup"
4865

@@ -170,7 +187,6 @@ def get_translation(language=None, tracker_home=None,
170187
"""
171188
mofiles = []
172189
# locale directory paths
173-
system_locale = gettext_module._default_localedir
174190
if tracker_home is None:
175191
tracker_locale = None
176192
else:
@@ -180,14 +196,16 @@ def get_translation(language=None, tracker_home=None,
180196
# add mofiles found in the tracker, then in the system locale directory
181197
if tracker_locale:
182198
mofiles.append(get_mofile(locales, tracker_locale))
183-
mofiles.append(get_mofile(locales, system_locale, DOMAIN))
199+
for system_locale in LOCALE_DIRS:
200+
mofiles.append(get_mofile(locales, system_locale, DOMAIN))
184201
# we want to fall back to english unless english is selected language
185202
if "en" not in locales:
186203
locales = find_locales("en")
187204
# add mofiles found in the tracker, then in the system locale directory
188205
if tracker_locale:
189206
mofiles.append(get_mofile(locales, tracker_locale))
190-
mofiles.append(get_mofile(locales, system_locale, DOMAIN))
207+
for system_locale in LOCALE_DIRS:
208+
mofiles.append(get_mofile(locales, system_locale, DOMAIN))
191209
# filter out elements that are not found
192210
mofiles = filter(None, mofiles)
193211
if mofiles:

0 commit comments

Comments
 (0)