Translate entities
This commit is contained in:
parent
8f85093eb8
commit
70ae60b9a4
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-11-27 22:20+0100\n"
|
||||
"POT-Creation-Date: 2020-11-27 22:31+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"
|
||||
@ -25,12 +25,12 @@ msgstr ""
|
||||
msgid "YOU ARE DEAD"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/interfaces.py:394
|
||||
#: squirrelbattle/interfaces.py:394 squirrelbattle/interfaces.py:398
|
||||
#, python-brace-format
|
||||
msgid "{name} hits {opponent}."
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/interfaces.py:405
|
||||
#: squirrelbattle/interfaces.py:405 squirrelbattle/interfaces.py:410
|
||||
#, python-brace-format
|
||||
msgid "{name} takes {amount} damage."
|
||||
msgstr ""
|
||||
@ -83,50 +83,89 @@ msgid ""
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/settings.py:21 squirrelbattle/tests/translations_test.py:21
|
||||
#: squirrelbattle/tests/translations_test.py:25
|
||||
msgid "Main key to move up"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/settings.py:22 squirrelbattle/tests/translations_test.py:23
|
||||
#: squirrelbattle/tests/translations_test.py:27
|
||||
msgid "Secondary key to move up"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/settings.py:23 squirrelbattle/tests/translations_test.py:25
|
||||
#: squirrelbattle/tests/translations_test.py:29
|
||||
msgid "Main key to move down"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/settings.py:24 squirrelbattle/tests/translations_test.py:27
|
||||
#: squirrelbattle/tests/translations_test.py:31
|
||||
msgid "Secondary key to move down"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/settings.py:25 squirrelbattle/tests/translations_test.py:29
|
||||
#: squirrelbattle/tests/translations_test.py:33
|
||||
msgid "Main key to move left"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/settings.py:26 squirrelbattle/tests/translations_test.py:31
|
||||
#: squirrelbattle/tests/translations_test.py:35
|
||||
msgid "Secondary key to move left"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/settings.py:27 squirrelbattle/tests/translations_test.py:33
|
||||
#: squirrelbattle/tests/translations_test.py:37
|
||||
msgid "Main key to move right"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/settings.py:29 squirrelbattle/tests/translations_test.py:35
|
||||
#: squirrelbattle/tests/translations_test.py:39
|
||||
msgid "Secondary key to move right"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/settings.py:30 squirrelbattle/tests/translations_test.py:37
|
||||
#: squirrelbattle/tests/translations_test.py:41
|
||||
msgid "Key to validate a menu"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/settings.py:31 squirrelbattle/tests/translations_test.py:39
|
||||
#: squirrelbattle/tests/translations_test.py:43
|
||||
msgid "Texture pack"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/settings.py:32 squirrelbattle/tests/translations_test.py:40
|
||||
#: squirrelbattle/tests/translations_test.py:44
|
||||
msgid "Language"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/interfaces.py:407
|
||||
#: squirrelbattle/interfaces.py:407 squirrelbattle/interfaces.py:412
|
||||
#, python-brace-format
|
||||
msgid "{name} dies."
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/tests/translations_test.py:47
|
||||
msgid "player"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/tests/translations_test.py:49
|
||||
msgid "tiger"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/tests/translations_test.py:50
|
||||
msgid "hedgehog"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/tests/translations_test.py:51
|
||||
msgid "rabbit"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/tests/translations_test.py:52
|
||||
msgid "teddy bear"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/tests/translations_test.py:54
|
||||
msgid "bomb"
|
||||
msgstr ""
|
||||
|
||||
#: squirrelbattle/tests/translations_test.py:55
|
||||
msgid "heart"
|
||||
msgstr ""
|
||||
|
Binary file not shown.
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-11-27 22:20+0100\n"
|
||||
"POT-Creation-Date: 2020-11-27 22:31+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"
|
||||
@ -25,12 +25,12 @@ msgstr "Inventaire :"
|
||||
msgid "YOU ARE DEAD"
|
||||
msgstr "VOUS ÊTES MORT"
|
||||
|
||||
#: squirrelbattle/interfaces.py:394
|
||||
#: squirrelbattle/interfaces.py:394 squirrelbattle/interfaces.py:398
|
||||
#, python-brace-format
|
||||
msgid "{name} hits {opponent}."
|
||||
msgstr "{name} frappe {opponent}."
|
||||
|
||||
#: squirrelbattle/interfaces.py:405
|
||||
#: squirrelbattle/interfaces.py:405 squirrelbattle/interfaces.py:410
|
||||
#, python-brace-format
|
||||
msgid "{name} takes {amount} damage."
|
||||
msgstr "{name} prend {amount} points de dégât."
|
||||
@ -89,50 +89,89 @@ msgstr ""
|
||||
"Votre sauvegarde semble corrompue. Elle a été supprimée."
|
||||
|
||||
#: squirrelbattle/settings.py:21 squirrelbattle/tests/translations_test.py:21
|
||||
#: squirrelbattle/tests/translations_test.py:25
|
||||
msgid "Main key to move up"
|
||||
msgstr "Touche principale pour aller vers le haut"
|
||||
|
||||
#: squirrelbattle/settings.py:22 squirrelbattle/tests/translations_test.py:23
|
||||
#: squirrelbattle/tests/translations_test.py:27
|
||||
msgid "Secondary key to move up"
|
||||
msgstr "Touche secondaire pour aller vers le haut"
|
||||
|
||||
#: squirrelbattle/settings.py:23 squirrelbattle/tests/translations_test.py:25
|
||||
#: squirrelbattle/tests/translations_test.py:29
|
||||
msgid "Main key to move down"
|
||||
msgstr "Touche principale pour aller vers le bas"
|
||||
|
||||
#: squirrelbattle/settings.py:24 squirrelbattle/tests/translations_test.py:27
|
||||
#: squirrelbattle/tests/translations_test.py:31
|
||||
msgid "Secondary key to move down"
|
||||
msgstr "Touche secondaire pour aller vers le bas"
|
||||
|
||||
#: squirrelbattle/settings.py:25 squirrelbattle/tests/translations_test.py:29
|
||||
#: squirrelbattle/tests/translations_test.py:33
|
||||
msgid "Main key to move left"
|
||||
msgstr "Touche principale pour aller vers la gauche"
|
||||
|
||||
#: squirrelbattle/settings.py:26 squirrelbattle/tests/translations_test.py:31
|
||||
#: squirrelbattle/tests/translations_test.py:35
|
||||
msgid "Secondary key to move left"
|
||||
msgstr "Touche secondaire pour aller vers la gauche"
|
||||
|
||||
#: squirrelbattle/settings.py:27 squirrelbattle/tests/translations_test.py:33
|
||||
#: squirrelbattle/tests/translations_test.py:37
|
||||
msgid "Main key to move right"
|
||||
msgstr "Touche principale pour aller vers la droite"
|
||||
|
||||
#: squirrelbattle/settings.py:29 squirrelbattle/tests/translations_test.py:35
|
||||
#: squirrelbattle/tests/translations_test.py:39
|
||||
msgid "Secondary key to move right"
|
||||
msgstr "Touche secondaire pour aller vers la droite"
|
||||
|
||||
#: squirrelbattle/settings.py:30 squirrelbattle/tests/translations_test.py:37
|
||||
#: squirrelbattle/tests/translations_test.py:41
|
||||
msgid "Key to validate a menu"
|
||||
msgstr "Touche pour valider un menu"
|
||||
|
||||
#: squirrelbattle/settings.py:31 squirrelbattle/tests/translations_test.py:39
|
||||
#: squirrelbattle/tests/translations_test.py:43
|
||||
msgid "Texture pack"
|
||||
msgstr "Pack de textures"
|
||||
|
||||
#: squirrelbattle/settings.py:32 squirrelbattle/tests/translations_test.py:40
|
||||
#: squirrelbattle/tests/translations_test.py:44
|
||||
msgid "Language"
|
||||
msgstr "Langue"
|
||||
|
||||
#: squirrelbattle/interfaces.py:407
|
||||
#: squirrelbattle/interfaces.py:407 squirrelbattle/interfaces.py:412
|
||||
#, python-brace-format
|
||||
msgid "{name} dies."
|
||||
msgstr "{name} meurt."
|
||||
|
||||
#: squirrelbattle/tests/translations_test.py:47
|
||||
msgid "player"
|
||||
msgstr "joueur"
|
||||
|
||||
#: squirrelbattle/tests/translations_test.py:49
|
||||
msgid "tiger"
|
||||
msgstr "tigre"
|
||||
|
||||
#: squirrelbattle/tests/translations_test.py:50
|
||||
msgid "hedgehog"
|
||||
msgstr "hérisson"
|
||||
|
||||
#: squirrelbattle/tests/translations_test.py:51
|
||||
msgid "rabbit"
|
||||
msgstr "lapin"
|
||||
|
||||
#: squirrelbattle/tests/translations_test.py:52
|
||||
msgid "teddy bear"
|
||||
msgstr "nounours"
|
||||
|
||||
#: squirrelbattle/tests/translations_test.py:54
|
||||
msgid "bomb"
|
||||
msgstr "bombe"
|
||||
|
||||
#: squirrelbattle/tests/translations_test.py:55
|
||||
msgid "heart"
|
||||
msgstr "cœur"
|
||||
|
@ -315,6 +315,10 @@ class Entity:
|
||||
from squirrelbattle.entities.items import Item
|
||||
return isinstance(self, Item)
|
||||
|
||||
@property
|
||||
def translated_name(self) -> str:
|
||||
return _(self.name.replace("_", " "))
|
||||
|
||||
@staticmethod
|
||||
def get_all_entity_classes():
|
||||
"""
|
||||
@ -392,8 +396,9 @@ class FightingEntity(Entity):
|
||||
Deals damage to the opponent, based on the stats
|
||||
"""
|
||||
return _("{name} hits {opponent}.")\
|
||||
.format(name=self.name, opponent=opponent.name) + " "\
|
||||
+ opponent.take_damage(self, self.strength)
|
||||
.format(name=_(self.translated_name.capitalize()),
|
||||
opponent=_(opponent.translated_name)) + " " + \
|
||||
opponent.take_damage(self, self.strength)
|
||||
|
||||
def take_damage(self, attacker: "Entity", amount: int) -> str:
|
||||
"""
|
||||
@ -403,8 +408,9 @@ class FightingEntity(Entity):
|
||||
if self.health <= 0:
|
||||
self.die()
|
||||
return _("{name} takes {amount} damage.")\
|
||||
.format(name=self.name, amount=str(amount)) \
|
||||
+ (" " + _("{name} dies.").format(name=self.name)
|
||||
.format(name=self.translated_name.capitalize(), amount=str(amount))\
|
||||
+ (" " + _("{name} dies.")
|
||||
.format(name=self.translated_name.capitalize())
|
||||
if self.health <= 0 else "")
|
||||
|
||||
def die(self) -> None:
|
||||
|
@ -7,9 +7,9 @@ class TestTranslations(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
setlocale("fr")
|
||||
|
||||
def test_translations(self) -> None:
|
||||
def test_main_menu_translation(self) -> None:
|
||||
"""
|
||||
Ensure that some strings are well-translated.
|
||||
Ensure that the main menu is translated.
|
||||
"""
|
||||
self.assertEqual(_("New game"), "Nouvelle partie")
|
||||
self.assertEqual(_("Resume"), "Continuer")
|
||||
@ -18,6 +18,10 @@ class TestTranslations(unittest.TestCase):
|
||||
self.assertEqual(_("Settings"), "Paramètres")
|
||||
self.assertEqual(_("Exit"), "Quitter")
|
||||
|
||||
def test_settings_menu_translation(self) -> None:
|
||||
"""
|
||||
Ensure that the settings menu is translated.
|
||||
"""
|
||||
self.assertEqual(_("Main key to move up"),
|
||||
"Touche principale pour aller vers le haut")
|
||||
self.assertEqual(_("Secondary key to move up"),
|
||||
@ -38,3 +42,14 @@ class TestTranslations(unittest.TestCase):
|
||||
"Touche pour valider un menu")
|
||||
self.assertEqual(_("Texture pack"), "Pack de textures")
|
||||
self.assertEqual(_("Language"), "Langue")
|
||||
|
||||
def test_entities_translation(self) -> None:
|
||||
self.assertEqual(_("player"), "joueur")
|
||||
|
||||
self.assertEqual(_("tiger"), "tigre")
|
||||
self.assertEqual(_("hedgehog"), "hérisson")
|
||||
self.assertEqual(_("rabbit"), "lapin")
|
||||
self.assertEqual(_("teddy bear"), "nounours")
|
||||
|
||||
self.assertEqual(_("bomb"), "bombe")
|
||||
self.assertEqual(_("heart"), "cœur")
|
||||
|
Loading…
Reference in New Issue
Block a user