Translate strings

This commit is contained in:
Yohann D'ANELLO 2020-11-27 20:42:19 +01:00
parent e3be4b4f3f
commit 2498fd2a61
8 changed files with 163 additions and 29 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:06+0100\n"
"POT-Creation-Date: 2020-11-27 20:39+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"
@ -17,6 +17,66 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: squirrelbattle/translations.py:7
msgid "Toto"
msgstr "Test"
#: squirrelbattle/display/statsdisplay.py:34
msgid "Inventory:"
msgstr ""
#: squirrelbattle/display/statsdisplay.py:39
msgid "YOU ARE DEAD"
msgstr ""
#: squirrelbattle/interfaces.py:394
#, python-brace-format
msgid "{name} hits {opponent}."
msgstr ""
#: squirrelbattle/interfaces.py:405
#, python-brace-format
msgid "{name} takes {amount} damage."
msgstr ""
#: squirrelbattle/menus.py:45
msgid "New game"
msgstr ""
#: squirrelbattle/menus.py:46
msgid "Resume"
msgstr ""
#: squirrelbattle/menus.py:47
msgid "Save"
msgstr ""
#: squirrelbattle/menus.py:48
msgid "Load"
msgstr ""
#: squirrelbattle/menus.py:49
msgid "Settings"
msgstr ""
#: squirrelbattle/menus.py:50
msgid "Exit"
msgstr ""
#: squirrelbattle/menus.py:71
msgid "Back"
msgstr ""
#: squirrelbattle/game.py:147
msgid ""
"Some keys are missing in your save file.\n"
"Your save seems to be corrupt. It got deleted."
msgstr ""
#: squirrelbattle/game.py:155
msgid ""
"No player was found on this map!\n"
"Maybe you died?"
msgstr ""
#: squirrelbattle/game.py:175
msgid ""
"The JSON file is not correct.\n"
"Your save seems corrupted.It got deleted."
msgstr ""

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:06+0100\n"
"POT-Creation-Date: 2020-11-27 20:39+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"
@ -17,6 +17,72 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: squirrelbattle/translations.py:7
msgid "Toto"
msgstr "Test"
#: squirrelbattle/display/statsdisplay.py:34
msgid "Inventory:"
msgstr "Inventaire :"
#: squirrelbattle/display/statsdisplay.py:39
msgid "YOU ARE DEAD"
msgstr "VOUS ÊTES MORT"
#: squirrelbattle/interfaces.py:394
#, python-brace-format
msgid "{name} hits {opponent}."
msgstr "{name} frappe {opponent}."
#: squirrelbattle/interfaces.py:405
#, python-brace-format
msgid "{name} takes {amount} damage."
msgstr "{name} prend {amount} points de dégât."
#: squirrelbattle/menus.py:45
msgid "New game"
msgstr "Nouvelle partie"
#: squirrelbattle/menus.py:46
msgid "Resume"
msgstr "Continuer"
#: squirrelbattle/menus.py:47
msgid "Save"
msgstr "Sauvegarder"
#: squirrelbattle/menus.py:48
msgid "Load"
msgstr "Charger"
#: squirrelbattle/menus.py:49
msgid "Settings"
msgstr "Paramètres"
#: squirrelbattle/menus.py:50
msgid "Exit"
msgstr "Quitter"
#: squirrelbattle/menus.py:71
msgid "Back"
msgstr "Retour"
#: squirrelbattle/game.py:147
msgid ""
"Some keys are missing in your save file.\n"
"Your save seems to be corrupt. It got deleted."
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
msgid ""
"No player was found on this map!\n"
"Maybe you died?"
msgstr ""
"Aucun joueur n'a été trouvé sur la carte !\n"
"Peut-être êtes-vous mort ?"
#: squirrelbattle/game.py:175
msgid ""
"The JSON file is not correct.\n"
"Your save seems corrupted.It got deleted."
msgstr ""
"Le fichier JSON de sauvegarde est incorrect.\n"
"Votre sauvegarde semble corrompue. Elle a été supprimée."

View File

@ -3,10 +3,10 @@
import curses
from ..entities.player import Player
from ..translations import gettext as _
from .display import Display
from squirrelbattle.entities.player import Player
class StatsDisplay(Display):
player: Player
@ -31,12 +31,12 @@ class StatsDisplay(Display):
self.player.dexterity, self.player.constitution)
self.addstr(self.pad, 3, 0, string3)
inventory_str = "Inventaire : " + "".join(
inventory_str = _("Inventory:") + " " + "".join(
self.pack[item.name.upper()] for item in self.player.inventory)
self.addstr(self.pad, 8, 0, inventory_str)
if self.player.dead:
self.addstr(self.pad, 10, 0, "VOUS ÊTES MORT",
self.addstr(self.pad, 10, 0, _("YOU ARE DEAD"),
curses.A_BOLD | curses.A_BLINK | curses.A_STANDOUT
| self.color_pair(3))

View File

@ -1,5 +1,6 @@
# Copyright (C) 2020 by ÿnérant, eichhornchen, nicomarg, charlse
# SPDX-License-Identifier: GPL-3.0-or-later
from json import JSONDecodeError
from random import randint
from typing import Any, Optional
@ -13,6 +14,7 @@ from .interfaces import Map, Logs
from .resources import ResourceManager
from .settings import Settings
from . import menus
from .translations import gettext as _
from typing import Callable
@ -142,16 +144,16 @@ class Game:
try:
self.map.load_state(d)
except KeyError:
self.message = "Some keys are missing in your save file.\n" \
"Your save seems to be corrupt. It got deleted."
self.message = _("Some keys are missing in your save file.\n"
"Your save seems to be corrupt. It got deleted.")
os.unlink(ResourceManager.get_config_path("save.json"))
self.display_actions(DisplayActions.UPDATE)
return
players = self.map.find_entities(Player)
if not players:
self.message = "No player was found on this map!\n" \
"Maybe you died?"
self.message = _("No player was found on this map!\n"
"Maybe you died?")
self.player.health = 0
self.display_actions(DisplayActions.UPDATE)
return
@ -170,8 +172,9 @@ class Game:
state = json.loads(f.read())
self.load_state(state)
except JSONDecodeError:
self.message = "The JSON file is not correct.\n" \
"Your save seems corrupted. It got deleted."
self.message = _("The JSON file is not correct.\n"
"Your save seems corrupted."
"It got deleted.")
os.unlink(file_path)
self.display_actions(DisplayActions.UPDATE)

View File

@ -6,7 +6,8 @@ from math import sqrt
from random import choice, randint
from typing import List, Optional
from squirrelbattle.display.texturepack import TexturePack
from .display.texturepack import TexturePack
from .translations import gettext as _
class Logs:
@ -390,7 +391,8 @@ class FightingEntity(Entity):
"""
Deals damage to the opponent, based on the stats
"""
return f"{self.name} hits {opponent.name}. "\
return _("{name} hits {opponent}.")\
.format(name=str(self), opponent=str(opponent)) + " "\
+ opponent.take_damage(self, self.strength)
def take_damage(self, attacker: "Entity", amount: int) -> str:
@ -400,8 +402,10 @@ class FightingEntity(Entity):
self.health -= amount
if self.health <= 0:
self.die()
return f"{self.name} takes {amount} damage."\
+ (f" {self.name} dies." if self.health <= 0 else "")
return _("{name} takes {amount} damage.")\
.format(name=str(self), amount=str(amount)) \
+ (" " + "{name} dies.".format(name=str(self))
if self.health <= 0 else "")
def die(self) -> None:
"""

View File

@ -7,6 +7,7 @@ from typing import Any, Optional
from .display.texturepack import TexturePack
from .enums import GameMode, KeyValues, DisplayActions
from .settings import Settings
from .translations import gettext as _
class Menu:
@ -41,12 +42,12 @@ class MainMenuValues(Enum):
"""
Values of the main menu
"""
START = 'Nouvelle partie'
RESUME = 'Continuer'
SAVE = 'Sauvegarder'
LOAD = 'Charger'
SETTINGS = 'Paramètres'
EXIT = 'Quitter'
START = _("New game")
RESUME = _("Resume")
SAVE = _("Save")
LOAD = _("Load")
SETTINGS = _("Settings")
EXIT = _("Exit")
def __str__(self):
return self.value
@ -67,7 +68,7 @@ class SettingsMenu(Menu):
def update_values(self, settings: Settings) -> None:
self.values = list(settings.__dict__.items())
self.values.append(("RETURN", ["", "Retour"]))
self.values.append(("RETURN", ["", _("Back")]))
def handle_key_pressed(self, key: Optional[KeyValues], raw_key: str,
game: Any) -> None: