Mercurial > p > roundup > code
diff roundup/i18n.py @ 7654:1471fcda252b
refactor: parameterize the root prefix number of characters
To make i18n work on windows, we need to clean the three character
root elements(drive letter, colon, backslash) from the front of the
various paths.
Parameterize the number of chars. Old way hard coded to 1, which
leaves :/ in the path and generates bad LOCALE_DIRS.
From issues getting Roundup running on windows discussed on mailing
list by Simon Eigeldinger.
Thread starts with:
https://sourceforge.net/p/roundup/mailman/message/41557096/
subject: Installing Roundup on Windows 2023-10-05.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Fri, 06 Oct 2023 20:45:25 -0400 |
| parents | 57f34b0b912c |
| children | a46675399a05 |
line wrap: on
line diff
--- a/roundup/i18n.py Fri Oct 06 16:07:43 2023 -0400 +++ b/roundup/i18n.py Fri Oct 06 20:45:25 2023 -0400 @@ -52,8 +52,11 @@ # locale root is prefix/share/locale. if os.name == "nt": _mo_path = [".."] * 4 + ["share", "locale"] + root_prefix_chars = 3 # remove c:\ or other drive letter else: _mo_path = [".."] * 5 + ["share", "locale"] + root_prefix_chars = 1 # remove / + _mo_path = os.path.normpath(os.path.join(msgfmt.__file__, *_mo_path)) if _mo_path not in LOCALE_DIRS: LOCALE_DIRS.append(_mo_path) @@ -67,18 +70,18 @@ for _N in 1, 2: path = os.path.dirname(path) # path is /usr/local/lib/python3.10/site-packages -_ldir = os.path.join(path, sys.prefix[1:], 'share', 'locale') +_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[1:], 'local', 'share', 'locale') +_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[1:], 'local', 'share', 'locale') + _ldir = os.path.join(path, sys.base_prefix[root_prefix_chars:], 'local', 'share', 'locale') if os.path.isdir(_ldir): LOCALE_DIRS.append(_ldir) - _ldir = os.path.join(path, sys.base_prefix[1:], 'share', 'locale') + _ldir = os.path.join(path, sys.base_prefix[root_prefix_chars:], 'share', 'locale') if os.path.isdir(_ldir): LOCALE_DIRS.append(_ldir) except AttributeError:
