Skip to content

Commit 5c6949b

Browse files
committed
fix: make running from code tree translate strings
Have Roundup's i18n add working_directorylocale/locale to the list of places searched for translation .mo files. This means: LANG=de python3 roundup/scripts/roundup_admin.py -i ... will be translated to German. Also document setting up locale/locale using 'make -C locale local_install' in developer doc.
1 parent b29c843 commit 5c6949b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

doc/developers.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,20 @@ sqlite`` and get a working Roundup server. This will start
119119
the server using the ``sqlite`` backend. The code is in the
120120
``roundup`` subdirectory.
121121

122+
To test internationalization in your environment, you have to
123+
process the locale sub-directory into a form that roundup's
124+
i18n code will recognize. To do this use:
125+
126+
make -C locale local_install
127+
128+
which will compile the ``.po`` source files into binary
129+
``.mo`` files and install them under
130+
``locale/locale/<LANGUAGE_CODE>/LC_MESSAGES/roundup.mo``. For
131+
German this will be
132+
``locale/locale/de/LC_MESSAGES/roundup.mo``. You will need
133+
``msgfmt`` from the the GNU gettext tools to be installed on
134+
your system.
135+
122136
Submitting Changes
123137
------------------
124138

roundup/i18n.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,32 @@
6767
# os.prefix should be /usr, /usr/local or root of virtualenv
6868
# strip leading / to make os.path.join work right.
6969
path = __file__
70-
for _N in 1, 2:
70+
71+
for _N in 1, 2: # remove roundup/i18n.py from path
7172
path = os.path.dirname(path)
7273
# path is /usr/local/lib/python3.10/site-packages
74+
7375
_ldir = os.path.join(path, sys.prefix[root_prefix_chars:], 'share', 'locale')
7476
if os.path.isdir(_ldir):
7577
LOCALE_DIRS.append(_ldir)
78+
7679
# try other places locale files are hidden on install
7780
_ldir = os.path.join(path, sys.prefix[root_prefix_chars:], 'local', 'share', 'locale')
7881
if os.path.isdir(_ldir):
7982
LOCALE_DIRS.append(_ldir)
83+
8084
try:
8185
_ldir = os.path.join(path, sys.base_prefix[root_prefix_chars:], 'local', 'share', 'locale')
8286
if os.path.isdir(_ldir):
8387
LOCALE_DIRS.append(_ldir)
8488
_ldir = os.path.join(path, sys.base_prefix[root_prefix_chars:], 'share', 'locale')
8589
if os.path.isdir(_ldir):
8690
LOCALE_DIRS.append(_ldir)
91+
92+
# make -C locale local_install - locale directory in roundup source tree
93+
_ldir = os.path.join(path, 'locale', 'locale')
94+
if os.path.isdir(_ldir):
95+
LOCALE_DIRS.append(_ldir)
8796
except AttributeError:
8897
pass # no base_prefix on 2.7
8998
del _ldir

0 commit comments

Comments
 (0)