Menu items are translated

This commit is contained in:
Yohann D'ANELLO 2020-11-27 21:44:17 +01:00
parent 4287b4f045
commit c151e0f656
5 changed files with 47 additions and 28 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-11-27 20:39+0100\n" "POT-Creation-Date: 2020-11-27 21:43+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -35,27 +35,27 @@ msgstr ""
msgid "{name} takes {amount} damage." msgid "{name} takes {amount} damage."
msgstr "" msgstr ""
#: squirrelbattle/menus.py:45 #: squirrelbattle/menus.py:45 squirrelbattle/tests/translations_test.py:14
msgid "New game" msgid "New game"
msgstr "" msgstr ""
#: squirrelbattle/menus.py:46 #: squirrelbattle/menus.py:46 squirrelbattle/tests/translations_test.py:15
msgid "Resume" msgid "Resume"
msgstr "" msgstr ""
#: squirrelbattle/menus.py:47 #: squirrelbattle/menus.py:47 squirrelbattle/tests/translations_test.py:17
msgid "Save" msgid "Save"
msgstr "" msgstr ""
#: squirrelbattle/menus.py:48 #: squirrelbattle/menus.py:48 squirrelbattle/tests/translations_test.py:16
msgid "Load" msgid "Load"
msgstr "" msgstr ""
#: squirrelbattle/menus.py:49 #: squirrelbattle/menus.py:49 squirrelbattle/tests/translations_test.py:18
msgid "Settings" msgid "Settings"
msgstr "" msgstr ""
#: squirrelbattle/menus.py:50 #: squirrelbattle/menus.py:50 squirrelbattle/tests/translations_test.py:19
msgid "Exit" msgid "Exit"
msgstr "" msgstr ""
@ -63,19 +63,19 @@ msgstr ""
msgid "Back" msgid "Back"
msgstr "" msgstr ""
#: squirrelbattle/game.py:147 #: squirrelbattle/game.py:147 squirrelbattle/game.py:148
msgid "" msgid ""
"Some keys are missing in your save file.\n" "Some keys are missing in your save file.\n"
"Your save seems to be corrupt. It got deleted." "Your save seems to be corrupt. It got deleted."
msgstr "" msgstr ""
#: squirrelbattle/game.py:155 #: squirrelbattle/game.py:155 squirrelbattle/game.py:156
msgid "" msgid ""
"No player was found on this map!\n" "No player was found on this map!\n"
"Maybe you died?" "Maybe you died?"
msgstr "" msgstr ""
#: squirrelbattle/game.py:175 #: squirrelbattle/game.py:175 squirrelbattle/game.py:176
msgid "" msgid ""
"The JSON file is not correct.\n" "The JSON file is not correct.\n"
"Your save seems corrupted.It got deleted." "Your save seems corrupted.It got deleted."

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-11-27 20:39+0100\n" "POT-Creation-Date: 2020-11-27 21:43+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -35,27 +35,27 @@ msgstr "{name} frappe {opponent}."
msgid "{name} takes {amount} damage." msgid "{name} takes {amount} damage."
msgstr "{name} prend {amount} points de dégât." msgstr "{name} prend {amount} points de dégât."
#: squirrelbattle/menus.py:45 #: squirrelbattle/menus.py:45 squirrelbattle/tests/translations_test.py:14
msgid "New game" msgid "New game"
msgstr "Nouvelle partie" msgstr "Nouvelle partie"
#: squirrelbattle/menus.py:46 #: squirrelbattle/menus.py:46 squirrelbattle/tests/translations_test.py:15
msgid "Resume" msgid "Resume"
msgstr "Continuer" msgstr "Continuer"
#: squirrelbattle/menus.py:47 #: squirrelbattle/menus.py:47 squirrelbattle/tests/translations_test.py:17
msgid "Save" msgid "Save"
msgstr "Sauvegarder" msgstr "Sauvegarder"
#: squirrelbattle/menus.py:48 #: squirrelbattle/menus.py:48 squirrelbattle/tests/translations_test.py:16
msgid "Load" msgid "Load"
msgstr "Charger" msgstr "Charger"
#: squirrelbattle/menus.py:49 #: squirrelbattle/menus.py:49 squirrelbattle/tests/translations_test.py:18
msgid "Settings" msgid "Settings"
msgstr "Paramètres" msgstr "Paramètres"
#: squirrelbattle/menus.py:50 #: squirrelbattle/menus.py:50 squirrelbattle/tests/translations_test.py:19
msgid "Exit" msgid "Exit"
msgstr "Quitter" msgstr "Quitter"
@ -63,7 +63,7 @@ msgstr "Quitter"
msgid "Back" msgid "Back"
msgstr "Retour" msgstr "Retour"
#: squirrelbattle/game.py:147 #: squirrelbattle/game.py:147 squirrelbattle/game.py:148
msgid "" msgid ""
"Some keys are missing in your save file.\n" "Some keys are missing in your save file.\n"
"Your save seems to be corrupt. It got deleted." "Your save seems to be corrupt. It got deleted."
@ -71,7 +71,7 @@ msgstr ""
"Certaines clés de votre ficher de sauvegarde sont manquantes.\n" "Certaines clés de votre ficher de sauvegarde sont manquantes.\n"
"Votre sauvegarde semble corrompue. Elle a été supprimée." "Votre sauvegarde semble corrompue. Elle a été supprimée."
#: squirrelbattle/game.py:155 #: squirrelbattle/game.py:155 squirrelbattle/game.py:156
msgid "" msgid ""
"No player was found on this map!\n" "No player was found on this map!\n"
"Maybe you died?" "Maybe you died?"
@ -79,7 +79,7 @@ msgstr ""
"Aucun joueur n'a été trouvé sur la carte !\n" "Aucun joueur n'a été trouvé sur la carte !\n"
"Peut-être êtes-vous mort ?" "Peut-être êtes-vous mort ?"
#: squirrelbattle/game.py:175 #: squirrelbattle/game.py:175 squirrelbattle/game.py:176
msgid "" msgid ""
"The JSON file is not correct.\n" "The JSON file is not correct.\n"
"Your save seems corrupted.It got deleted." "Your save seems corrupted.It got deleted."

View File

@ -18,7 +18,7 @@ class MenuDisplay(Display):
def update_menu(self, menu: Menu) -> None: def update_menu(self, menu: Menu) -> None:
self.menu = menu self.menu = menu
self.trueheight = len(self.values) self.trueheight = len(self.values)
self.truewidth = max([len(a) for a in self.values]) self.truewidth = max([len(str(a)) for a in self.values])
# Menu values are printed in pad # Menu values are printed in pad
self.pad = self.newpad(self.trueheight, self.truewidth + 2) self.pad = self.newpad(self.trueheight, self.truewidth + 2)

View File

@ -42,15 +42,15 @@ class MainMenuValues(Enum):
""" """
Values of the main menu Values of the main menu
""" """
START = _("New game") START = "New game"
RESUME = _("Resume") RESUME = "Resume"
SAVE = _("Save") SAVE = "Save"
LOAD = _("Load") LOAD = "Load"
SETTINGS = _("Settings") SETTINGS = "Settings"
EXIT = _("Exit") EXIT = "Exit"
def __str__(self): def __str__(self):
return self.value return _(self.value)
class MainMenu(Menu): class MainMenu(Menu):

View File

@ -0,0 +1,19 @@
import unittest
from squirrelbattle.translations import gettext as _, setlocale
class TestTranslations(unittest.TestCase):
def setUp(self) -> None:
setlocale("fr")
def test_translations(self):
"""
Ensure that some strings are well-translated.
"""
self.assertEqual(_("New game"), "Nouvelle partie")
self.assertEqual(_("Resume"), "Continuer")
self.assertEqual(_("Load"), "Charger")
self.assertEqual(_("Save"), "Sauvegarder")
self.assertEqual(_("Settings"), "Paramètres")
self.assertEqual(_("Exit"), "Quitter")