Mercurial > p > roundup > code
changeset 7759:a46675399a05
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.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 02 Mar 2024 00:47:19 -0500 |
| parents | 20a87d228240 |
| children | 481235e743bc |
| files | doc/developers.txt roundup/i18n.py |
| diffstat | 2 files changed, 24 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/developers.txt Fri Mar 01 16:22:15 2024 -0500 +++ b/doc/developers.txt Sat Mar 02 00:47:19 2024 -0500 @@ -119,6 +119,20 @@ the server using the ``sqlite`` backend. The code is in the ``roundup`` subdirectory. +To test internationalization in your environment, you have to +process the locale sub-directory into a form that roundup's +i18n code will recognize. To do this use: + + make -C locale local_install + +which will compile the ``.po`` source files into binary +``.mo`` files and install them under +``locale/locale/<LANGUAGE_CODE>/LC_MESSAGES/roundup.mo``. For +German this will be +``locale/locale/de/LC_MESSAGES/roundup.mo``. You will need +``msgfmt`` from the the GNU gettext tools to be installed on +your system. + Submitting Changes ------------------
--- a/roundup/i18n.py Fri Mar 01 16:22:15 2024 -0500 +++ b/roundup/i18n.py Sat Mar 02 00:47:19 2024 -0500 @@ -67,16 +67,20 @@ # os.prefix should be /usr, /usr/local or root of virtualenv # strip leading / to make os.path.join work right. path = __file__ -for _N in 1, 2: + +for _N in 1, 2: # remove roundup/i18n.py from path path = os.path.dirname(path) # path is /usr/local/lib/python3.10/site-packages + _ldir = os.path.join(path, sys.prefix[root_prefix_chars:], 'share', 'locale') if os.path.isdir(_ldir): LOCALE_DIRS.append(_ldir) + # try other places locale files are hidden on install _ldir = os.path.join(path, sys.prefix[root_prefix_chars:], 'local', 'share', 'locale') if os.path.isdir(_ldir): LOCALE_DIRS.append(_ldir) + try: _ldir = os.path.join(path, sys.base_prefix[root_prefix_chars:], 'local', 'share', 'locale') if os.path.isdir(_ldir): @@ -84,6 +88,11 @@ _ldir = os.path.join(path, sys.base_prefix[root_prefix_chars:], 'share', 'locale') if os.path.isdir(_ldir): LOCALE_DIRS.append(_ldir) + + # make -C locale local_install - locale directory in roundup source tree + _ldir = os.path.join(path, 'locale', 'locale') + if os.path.isdir(_ldir): + LOCALE_DIRS.append(_ldir) except AttributeError: pass # no base_prefix on 2.7 del _ldir
