From 8aad15f07b6821e024665323049ac5d49c92688d Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 28 Nov 2020 03:04:28 +0100 Subject: [PATCH] Move translation files in the module --- .../locale}/en/LC_MESSAGES/squirrelbattle.mo | Bin 337 -> 368 bytes .../locale}/en/LC_MESSAGES/squirrelbattle.po | 2 +- .../locale}/fr/LC_MESSAGES/squirrelbattle.mo | Bin 2607 -> 2638 bytes .../locale}/fr/LC_MESSAGES/squirrelbattle.po | 0 squirrelbattle/translations.py | 21 +++++++++++------- 5 files changed, 14 insertions(+), 9 deletions(-) rename {locale => squirrelbattle/locale}/en/LC_MESSAGES/squirrelbattle.mo (59%) rename {locale => squirrelbattle/locale}/en/LC_MESSAGES/squirrelbattle.po (99%) rename {locale => squirrelbattle/locale}/fr/LC_MESSAGES/squirrelbattle.mo (84%) rename {locale => squirrelbattle/locale}/fr/LC_MESSAGES/squirrelbattle.po (100%) 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 6c5906d1cd061dff54de8b533942893de34efc9e..14164ec0ffb6694d6c55f833f37252bf09f9cc75 100644 GIT binary patch delta 84 zcmcb}^nq!D3ZvOXRSnnT!qUv5qSTzE#FCPnR0U%_LlZqiuAtO{{Gt+F-{SPl6kVs% d^kUtRd@BW*T3v`@hvcHfykfolqV$Qy_W;)<9*O_} delta 53 zcmeysbdhO-3ZwW$RSmTOM`v$GcUOfl*Pviee?P9E)Pnq?5?$Zo^vo1pr_%Id-H?1M Jg^82y0RXnd5qJOq 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 12e6fe990a48a5dcee90cc5a5049f39393074960..eb2e033a3be0be6f3613020253fa56fa6f3334af 100644 GIT binary patch delta 359 zcmZ24a!zD}4r9F;BLhPzD+2=?0|UbvAi)l#Hv?%NAiWz%O9SZ>KpKb`o&X7u{A(bs z0i-_zX>A}a0~7?&9za?XNS6RBYJs`Bn-rwYm_+4#`D{dBuA9Md_Q@vo^2*03~%f A8vpr)_4~CeqbJTp}`{xN(d=oMIFg$dCg??Vm7#S4`o@GRbC= zzKH=ev4lg^@s3`6qPqWfi}?$Pc>X~Ks(=ovgA?rG9D^7qrHvU>4@{B2%hGa#4B1im zlkBbaBN8DOtG}V2{-Ki+Ve(=jfv#=VUULL$xqLZSFk&sE-Y8ZpqnQ@op0&R73xSj+ AjQ{`u 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)