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 ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -35,27 +35,27 @@ msgstr ""
msgid "{name} takes {amount} damage."
msgstr ""
#: squirrelbattle/menus.py:45
#: squirrelbattle/menus.py:45 squirrelbattle/tests/translations_test.py:14
msgid "New game"
msgstr ""
#: squirrelbattle/menus.py:46
#: squirrelbattle/menus.py:46 squirrelbattle/tests/translations_test.py:15
msgid "Resume"
msgstr ""
#: squirrelbattle/menus.py:47
#: squirrelbattle/menus.py:47 squirrelbattle/tests/translations_test.py:17
msgid "Save"
msgstr ""
#: squirrelbattle/menus.py:48
#: squirrelbattle/menus.py:48 squirrelbattle/tests/translations_test.py:16
msgid "Load"
msgstr ""
#: squirrelbattle/menus.py:49
#: squirrelbattle/menus.py:49 squirrelbattle/tests/translations_test.py:18
msgid "Settings"
msgstr ""
#: squirrelbattle/menus.py:50
#: squirrelbattle/menus.py:50 squirrelbattle/tests/translations_test.py:19
msgid "Exit"
msgstr ""
@ -63,19 +63,19 @@ msgstr ""
msgid "Back"
msgstr ""
#: squirrelbattle/game.py:147
#: squirrelbattle/game.py:147 squirrelbattle/game.py:148
msgid ""
"Some keys are missing in your save file.\n"
"Your save seems to be corrupt. It got deleted."
msgstr ""
#: squirrelbattle/game.py:155
#: squirrelbattle/game.py:155 squirrelbattle/game.py:156
msgid ""
"No player was found on this map!\n"
"Maybe you died?"
msgstr ""
#: squirrelbattle/game.py:175
#: squirrelbattle/game.py:175 squirrelbattle/game.py:176
msgid ""
"The JSON file is not correct.\n"
"Your save seems corrupted.It got deleted."

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -35,27 +35,27 @@ msgstr "{name} frappe {opponent}."
msgid "{name} takes {amount} damage."
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"
msgstr "Nouvelle partie"
#: squirrelbattle/menus.py:46
#: squirrelbattle/menus.py:46 squirrelbattle/tests/translations_test.py:15
msgid "Resume"
msgstr "Continuer"
#: squirrelbattle/menus.py:47
#: squirrelbattle/menus.py:47 squirrelbattle/tests/translations_test.py:17
msgid "Save"
msgstr "Sauvegarder"
#: squirrelbattle/menus.py:48
#: squirrelbattle/menus.py:48 squirrelbattle/tests/translations_test.py:16
msgid "Load"
msgstr "Charger"
#: squirrelbattle/menus.py:49
#: squirrelbattle/menus.py:49 squirrelbattle/tests/translations_test.py:18
msgid "Settings"
msgstr "Paramètres"
#: squirrelbattle/menus.py:50
#: squirrelbattle/menus.py:50 squirrelbattle/tests/translations_test.py:19
msgid "Exit"
msgstr "Quitter"
@ -63,7 +63,7 @@ msgstr "Quitter"
msgid "Back"
msgstr "Retour"
#: squirrelbattle/game.py:147
#: squirrelbattle/game.py:147 squirrelbattle/game.py:148
msgid ""
"Some keys are missing in your save file.\n"
"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"
"Votre sauvegarde semble corrompue. Elle a été supprimée."
#: squirrelbattle/game.py:155
#: squirrelbattle/game.py:155 squirrelbattle/game.py:156
msgid ""
"No player was found on this map!\n"
"Maybe you died?"
@ -79,7 +79,7 @@ msgstr ""
"Aucun joueur n'a été trouvé sur la carte !\n"
"Peut-être êtes-vous mort ?"
#: squirrelbattle/game.py:175
#: squirrelbattle/game.py:175 squirrelbattle/game.py:176
msgid ""
"The JSON file is not correct.\n"
"Your save seems corrupted.It got deleted."

View File

@ -18,7 +18,7 @@ class MenuDisplay(Display):
def update_menu(self, menu: Menu) -> None:
self.menu = menu
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
self.pad = self.newpad(self.trueheight, self.truewidth + 2)

View File

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