LibreTranslate/scripts/compile_locales.py

31 lines
1.1 KiB
Python
Raw Permalink Normal View History

2023-01-04 20:36:26 +00:00
#!/usr/bin/env python
import os
2023-07-09 10:29:11 +00:00
import sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
2023-01-04 20:36:26 +00:00
from babel.messages.frontend import main as pybabel
if __name__ == "__main__":
2023-01-06 20:27:04 +00:00
if len(sys.argv) >= 2 and sys.argv[1] == 'mdtable':
from libretranslate.locales import get_available_locales
locales = get_available_locales(only_reviewed=False, sort_by_name=True)
print("Language | Reviewed | Weblate Link")
print("-------- | -------- | ------------")
2023-01-04 20:36:26 +00:00
2023-01-06 20:27:04 +00:00
for l in locales:
link = "https://hosted.weblate.org/translate/libretranslate/app/%s/" % l['code']
if l['code'] == 'en':
link = "https://hosted.weblate.org/projects/libretranslate/app/"
2023-07-09 10:29:11 +00:00
print("{} | {} | {}".format(l['name'], ':heavy_check_mark:' if l['reviewed'] else '', "[Edit](%s)" % link))
2023-01-06 20:27:04 +00:00
else:
locales_dir = os.path.join("libretranslate", "locales")
if not os.path.isdir(locales_dir):
os.makedirs(locales_dir)
print("Compiling locales")
sys.argv = ["", "compile", "-f", "-d", locales_dir]
pybabel()
2023-01-04 20:36:26 +00:00