diff --git a/locale/en/LC_MESSAGES/squirrelbattle.mo b/squirrelbattle/locale/en/LC_MESSAGES/squirrelbattle.mo similarity index 59% rename from locale/en/LC_MESSAGES/squirrelbattle.mo rename to squirrelbattle/locale/en/LC_MESSAGES/squirrelbattle.mo index 6c5906d..14164ec 100644 Binary files a/locale/en/LC_MESSAGES/squirrelbattle.mo and b/squirrelbattle/locale/en/LC_MESSAGES/squirrelbattle.mo differ diff --git a/locale/en/LC_MESSAGES/squirrelbattle.po b/squirrelbattle/locale/en/LC_MESSAGES/squirrelbattle.po similarity index 99% rename from locale/en/LC_MESSAGES/squirrelbattle.po rename to squirrelbattle/locale/en/LC_MESSAGES/squirrelbattle.po index 21e45e6..9600c79 100644 --- a/locale/en/LC_MESSAGES/squirrelbattle.po +++ b/squirrelbattle/locale/en/LC_MESSAGES/squirrelbattle.po @@ -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 \n" "Language-Team: LANGUAGE \n" diff --git a/locale/fr/LC_MESSAGES/squirrelbattle.mo b/squirrelbattle/locale/fr/LC_MESSAGES/squirrelbattle.mo similarity index 84% rename from locale/fr/LC_MESSAGES/squirrelbattle.mo rename to squirrelbattle/locale/fr/LC_MESSAGES/squirrelbattle.mo index 12e6fe9..eb2e033 100644 Binary files a/locale/fr/LC_MESSAGES/squirrelbattle.mo and b/squirrelbattle/locale/fr/LC_MESSAGES/squirrelbattle.mo differ diff --git a/locale/fr/LC_MESSAGES/squirrelbattle.po b/squirrelbattle/locale/fr/LC_MESSAGES/squirrelbattle.po similarity index 100% rename from locale/fr/LC_MESSAGES/squirrelbattle.po rename to squirrelbattle/locale/fr/LC_MESSAGES/squirrelbattle.po diff --git a/squirrelbattle/translations.py b/squirrelbattle/translations.py index 1cee88b..7a0e524 100644 --- a/squirrelbattle/translations.py +++ b/squirrelbattle/translations.py @@ -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)