Fixed grammar, unified the docstring's format and added documentation to some classes that did not have any. Closes #32.

This commit is contained in:
eichhornchen
2020-12-13 21:29:25 +01:00
parent 3f62fbaa2b
commit 646e0063be
24 changed files with 254 additions and 170 deletions

View File

@ -13,7 +13,7 @@ class Translator:
"""
This module uses gettext to translate strings.
Translator.setlocale defines the language of the strings,
then gettext() translates the message.
then gettext() translates the messages.
"""
SUPPORTED_LOCALES: List[str] = ["de", "en", "es", "fr"]
locale: str = "en"
@ -22,7 +22,7 @@ class Translator:
@classmethod
def refresh_translations(cls) -> None:
"""
Load compiled translations.
Loads compiled translations.
"""
for language in cls.SUPPORTED_LOCALES:
rep = Path(__file__).parent / "locale" / language / "LC_MESSAGES"
@ -37,7 +37,7 @@ class Translator:
@classmethod
def setlocale(cls, lang: str) -> None:
"""
Define the language used to translate the game.
Defines the language used to translate the game.
The language must be supported, otherwise nothing is done.
"""
lang = lang[:2]
@ -51,7 +51,7 @@ class Translator:
@classmethod
def makemessages(cls) -> None: # pragma: no cover
"""
Analyse all strings in the project and extract them.
Analyses all strings in the project and extracts them.
"""
for language in cls.SUPPORTED_LOCALES:
if language == "en":
@ -83,7 +83,7 @@ class Translator:
@classmethod
def compilemessages(cls) -> None:
"""
Compile translation messages from source files.
Compiles translation messages from source files.
"""
for language in cls.SUPPORTED_LOCALES:
if language == "en":
@ -99,7 +99,7 @@ class Translator:
def gettext(message: str) -> str:
"""
Translate a message.
Translates a message.
"""
return Translator.get_translator().gettext(message)