Skip to content

Commit a4bfdd4

Browse files
committed
i18n: build_translations revisited
1 parent b4c7a17 commit a4bfdd4

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

setup.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,13 @@ def finalize_options(self):
5252
pass
5353

5454
def run(self):
55-
src_path = os.path.join(os.path.realpath(''), 'po')
56-
for filename in os.listdir(src_path):
57-
if (not os.path.isfile(os.path.join(src_path, filename)) or
58-
not filename.endswith('.po')):
59-
continue
55+
for src in glob.iglob(os.path.join('po', '[a-z][a-z]_[A-Z][A-Z].po')):
6056

61-
lang = filename[:-3]
57+
# remove 'po/' (the directory) and '.po' (the extension)
58+
lang = src[3:-3]
6259
dest_path = os.path.join('build', 'share', 'locale',
63-
lang, 'LC_MESSAGES')
64-
65-
src = os.path.join(src_path, filename)
66-
dest = os.path.join(dest_path, 'bpython.mo')
60+
lang, 'LC_MESSAGES', '')
61+
dest = dest_path + 'bpython.mo'
6762

6863
if not os.path.exists(dest_path):
6964
os.makedirs(dest_path)
@@ -83,12 +78,8 @@ def run(self):
8378
(os.path.join('share', 'applications'), ['data/bpython.desktop']),
8479
]
8580
# localization
86-
l10n_dir = os.path.join('share', 'locale')
87-
for langfile in os.listdir('po'):
88-
if not os.path.isfile(langfile) or not langfile.endswith('.po'):
89-
continue
90-
91-
lang_path = os.path.join(l10n_dir, langfile[:-3], 'LC_MESSAGES')
81+
for langfile in glob.iglob(os.path.join('po', '[a-z][a-z]_[A-Z][A-Z].po')):
82+
lang_path = os.path.join('share', 'locale', langfile[3:-3], 'LC_MESSAGES')
9283
data_files.append((lang_path, ['build/%s/bpython.mo' % lang_path]))
9384

9485

0 commit comments

Comments
 (0)