Create functions that call xgettext or msgfmt
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import gettext as gt
|
||||
import subprocess
|
||||
from typing import Any, List
|
||||
|
||||
|
||||
@ -36,6 +37,32 @@ class Translator:
|
||||
def get_translator(cls) -> Any:
|
||||
return cls.translators.get(cls.locale)
|
||||
|
||||
@classmethod
|
||||
def makemessages(cls) -> None:
|
||||
for language in cls.SUPPORTED_LOCALES:
|
||||
args = ["find", "squirrelbattle/", "-iname", "*.py"]
|
||||
find = subprocess.Popen(args, stdout=subprocess.PIPE)
|
||||
args = ["xargs", "xgettext", "--from-code", "utf-8",
|
||||
"--join-existing",
|
||||
"--add-comments",
|
||||
"--package-name=squirrelbattle",
|
||||
"--package-version=3.14.1",
|
||||
"--copyright-holder=ÿnérant, eichhornchen, "
|
||||
"nicomarg, charlse",
|
||||
"--msgid-bugs-address=squirrel-battle@crans.org",
|
||||
"-o", f"locale/{language}/LC_MESSAGES/squirrelbattle.po"]
|
||||
print(f"Make {language} messages...")
|
||||
subprocess.Popen(args, stdin=find.stdout)
|
||||
|
||||
@classmethod
|
||||
def compilemessages(cls) -> None:
|
||||
for language in cls.SUPPORTED_LOCALES:
|
||||
args = ["msgfmt", "--check-format",
|
||||
"-o", f"locale/{language}/LC_MESSAGES/squirrelbattle.mo",
|
||||
f"locale/{language}/LC_MESSAGES/squirrelbattle.po"]
|
||||
print(f"Compiling {language} messages...")
|
||||
subprocess.Popen(args)
|
||||
|
||||
|
||||
def gettext(message: str) -> str:
|
||||
"""
|
||||
|
Reference in New Issue
Block a user