|
52 | 52 | # locale root is prefix/share/locale.
|
53 | 53 | if os.name == "nt":
|
54 | 54 | _mo_path = [".."] * 4 + ["share", "locale"]
|
| 55 | + root_prefix_chars = 3 # remove c:\ or other drive letter |
55 | 56 | else:
|
56 | 57 | _mo_path = [".."] * 5 + ["share", "locale"]
|
| 58 | + root_prefix_chars = 1 # remove / |
| 59 | + |
57 | 60 | _mo_path = os.path.normpath(os.path.join(msgfmt.__file__, *_mo_path))
|
58 | 61 | if _mo_path not in LOCALE_DIRS:
|
59 | 62 | LOCALE_DIRS.append(_mo_path)
|
|
67 | 70 | for _N in 1, 2:
|
68 | 71 | path = os.path.dirname(path)
|
69 | 72 | # path is /usr/local/lib/python3.10/site-packages
|
70 |
| -_ldir = os.path.join(path, sys.prefix[1:], 'share', 'locale') |
| 73 | +_ldir = os.path.join(path, sys.prefix[root_prefix_chars:], 'share', 'locale') |
71 | 74 | if os.path.isdir(_ldir):
|
72 | 75 | LOCALE_DIRS.append(_ldir)
|
73 | 76 | # try other places locale files are hidden on install
|
74 |
| -_ldir = os.path.join(path, sys.prefix[1:], 'local', 'share', 'locale') |
| 77 | +_ldir = os.path.join(path, sys.prefix[root_prefix_chars:], 'local', 'share', 'locale') |
75 | 78 | if os.path.isdir(_ldir):
|
76 | 79 | LOCALE_DIRS.append(_ldir)
|
77 | 80 | try:
|
78 |
| - _ldir = os.path.join(path, sys.base_prefix[1:], 'local', 'share', 'locale') |
| 81 | + _ldir = os.path.join(path, sys.base_prefix[root_prefix_chars:], 'local', 'share', 'locale') |
79 | 82 | if os.path.isdir(_ldir):
|
80 | 83 | LOCALE_DIRS.append(_ldir)
|
81 |
| - _ldir = os.path.join(path, sys.base_prefix[1:], 'share', 'locale') |
| 84 | + _ldir = os.path.join(path, sys.base_prefix[root_prefix_chars:], 'share', 'locale') |
82 | 85 | if os.path.isdir(_ldir):
|
83 | 86 | LOCALE_DIRS.append(_ldir)
|
84 | 87 | except AttributeError:
|
|
0 commit comments