Move translation files in the module

This commit is contained in:
Yohann D'ANELLO 2020-11-28 03:04:28 +01:00
parent ffc8b90441
commit 8aad15f07b
5 changed files with 14 additions and 9 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: squirrelbattle 3.14.1\n"
"Report-Msgid-Bugs-To: squirrel-battle@crans.org\n"
"POT-Creation-Date: 2020-11-28 02:50+0100\n"
"POT-Creation-Date: 2020-11-28 03:01+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -3,6 +3,7 @@
import gettext as gt
import subprocess
from pathlib import Path
from typing import Any, List
@ -19,7 +20,7 @@ class Translator:
for language in SUPPORTED_LOCALES:
translators[language] = gt.translation(
"squirrelbattle",
localedir="locale",
localedir=Path(__file__).parent / "locale",
languages=[language],
)
@ -38,10 +39,11 @@ class Translator:
return cls.translators.get(cls.locale)
@classmethod
def makemessages(cls) -> None:
def makemessages(cls) -> None: # pragma: no cover
for language in cls.SUPPORTED_LOCALES:
args = ["find", "squirrelbattle/", "-iname", "*.py"]
find = subprocess.Popen(args, stdout=subprocess.PIPE)
args = ["find", "squirrelbattle", "-iname", "*.py"]
find = subprocess.Popen(args, cwd=Path(__file__).parent.parent,
stdout=subprocess.PIPE)
args = ["xargs", "xgettext", "--from-code", "utf-8",
"--join-existing",
"--add-comments",
@ -50,16 +52,19 @@ class Translator:
"--copyright-holder=ÿnérant, eichhornchen, "
"nicomarg, charlse",
"--msgid-bugs-address=squirrel-battle@crans.org",
"-o", f"locale/{language}/LC_MESSAGES/squirrelbattle.po"]
"-o", Path(__file__).parent / "locale" / language
/ "LC_MESSAGES" / "squirrelbattle.po"]
print(f"Make {language} messages...")
subprocess.Popen(args, stdin=find.stdout)
@classmethod
def compilemessages(cls) -> None:
def compilemessages(cls) -> None: # pragma: no cover
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"]
"-o", Path(__file__).parent / "locale" / language
/ "LC_MESSAGES" / "squirrelbattle.mo",
Path(__file__).parent / "locale" / language
/ "LC_MESSAGES" / "squirrelbattle.po"]
print(f"Compiling {language} messages...")
subprocess.Popen(args)