Replace list_translation_files() in setup.py

This commit is contained in:
Chris Mayo 2021-12-30 19:27:04 +00:00
parent fb03843b6c
commit 3aad37b86e

View file

@ -93,11 +93,14 @@ class MyBuild(build):
def run(self):
if COMPILE_TRANSLATIONS:
for (src, bld_path) in list_translation_files():
bld_path = Path(self.build_lib, bld_path)
pofile = polib.pofile(src)
bld_path.parent.mkdir(exist_ok=True, parents=True)
pofile.save_as_mofile(str(bld_path))
for po in Path("po").glob("*.po"):
mo = Path(
self.build_lib, "linkcheck", "data", "locale",
po.stem, "LC_MESSAGES", AppName.lower()
).with_suffix(".mo")
pofile = polib.pofile(str(po))
mo.parent.mkdir(exist_ok=True, parents=True)
pofile.save_as_mofile(str(mo))
super().run()
@ -134,17 +137,6 @@ class MyInstallData(install_data):
os.chmod(path, mode)
def list_translation_files():
"""Return list of translation files and their build paths."""
for po in Path("po").glob("*.po"):
mo = Path(
"locale", po.stem, "LC_MESSAGES", AppName.lower()
).with_suffix(".mo")
build_mo = Path("linkcheck", "data", mo)
build_mo.parent.mkdir(exist_ok=True, parents=True)
yield (str(po), build_mo)
# scripts
myname = "LinkChecker Authors"
myemail = ""