Create functions that call xgettext or msgfmt
This commit is contained in:
parent
7d02604407
commit
ffc8b90441
@ -1,14 +1,14 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# Copyright (C) YEAR ÿnérant, eichhornchen, nicomarg, charlse
|
||||
# This file is distributed under the same license as the squirrelbattle package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-11-27 22:31+0100\n"
|
||||
"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"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -1,14 +1,14 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# Copyright (C) YEAR ÿnérant, eichhornchen, nicomarg, charlse
|
||||
# This file is distributed under the same license as the squirrelbattle package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-11-27 22:31+0100\n"
|
||||
"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"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -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:
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user