mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2025-05-14 05:52:55 +00:00
Translation scripts
This commit is contained in:
parent
bd9a153773
commit
05900ff556
8 changed files with 71 additions and 5 deletions
31
update_translations.py
Executable file
31
update_translations.py
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env python
|
||||
import sys
|
||||
import os
|
||||
from babel.messages.frontend import main as pybabel
|
||||
from libretranslate.language import load_languages
|
||||
|
||||
# Update strings
|
||||
if __name__ == "__main__":
|
||||
translations_dir = os.path.join("libretranslate", "translations")
|
||||
if not os.path.isdir(translations_dir):
|
||||
os.makedirs(translations_dir)
|
||||
|
||||
messagespot = os.path.join(translations_dir, "messages.pot")
|
||||
print("Updating %s" % messagespot)
|
||||
sys.argv = ["", "extract", "-F", "babel.cfg", "-o", messagespot, "libretranslate"]
|
||||
pybabel()
|
||||
|
||||
# Load list of languages
|
||||
print("Loading languages")
|
||||
languages = [l.code for l in load_languages() if l != "en"]
|
||||
print(languages)
|
||||
languages = ["it"]
|
||||
|
||||
for l in languages:
|
||||
cmd = "init"
|
||||
if os.path.isdir(os.path.join(translations_dir, l)):
|
||||
cmd = "update"
|
||||
|
||||
sys.argv = ["", cmd, "-i", messagespot, "-d", translations_dir, "-l", l]
|
||||
pybabel()
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue