Merging master into village, conflicts were solved
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
|
||||
import gettext as gt
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from typing import Any, List
|
||||
@ -53,6 +54,9 @@ class Translator:
|
||||
Analyse all strings in the project and extract them.
|
||||
"""
|
||||
for language in cls.SUPPORTED_LOCALES:
|
||||
if language == "en":
|
||||
# Don't translate the main language
|
||||
continue
|
||||
file_name = Path(__file__).parent / "locale" / language \
|
||||
/ "LC_MESSAGES" / "squirrelbattle.po"
|
||||
args = ["find", "squirrelbattle", "-iname", "*.py"]
|
||||
@ -65,9 +69,14 @@ class Translator:
|
||||
"--copyright-holder=ÿnérant, eichhornchen, "
|
||||
"nicomarg, charlse",
|
||||
"--msgid-bugs-address=squirrel-battle@crans.org",
|
||||
"--sort-by-file",
|
||||
"-o", file_name]
|
||||
if file_name.is_file():
|
||||
args.append("--join-existing")
|
||||
with open(file_name, "r") as f:
|
||||
content = f.read()
|
||||
with open(file_name, "w") as f:
|
||||
f.write(re.sub("#:.*\n", "", content))
|
||||
print(f"Make {language} messages...")
|
||||
subprocess.Popen(args, stdin=find.stdout).wait()
|
||||
|
||||
@ -77,6 +86,8 @@ class Translator:
|
||||
Compile translation messages from source files.
|
||||
"""
|
||||
for language in cls.SUPPORTED_LOCALES:
|
||||
if language == "en":
|
||||
continue
|
||||
args = ["msgfmt", "--check-format",
|
||||
"-o", Path(__file__).parent / "locale" / language
|
||||
/ "LC_MESSAGES" / "squirrelbattle.mo",
|
||||
|
Reference in New Issue
Block a user