Skip to content

Commit b4c7a17

Browse files
committed
i18n: more dynamic translations loading
1 parent 722d822 commit b4c7a17

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

bpython/translations.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1+
import os.path
12
import gettext
23

3-
translation = gettext.translation('bpython')
4-
_ = translation.ugettext
4+
try:
5+
translation = gettext.translation('bpython')
6+
except IOError:
7+
# try to load .mo files created with 'python setup.py build_translation'
8+
# from the build/ directory
9+
try:
10+
translation = gettext.translation('bpython',
11+
os.path.join('build', 'share', 'locale'))
12+
except IOError:
13+
translation = None
14+
15+
if translation is None:
16+
def _(s):
17+
return s
18+
else:
19+
_ = translation.ugettext

0 commit comments

Comments
 (0)