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

@ -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:
"""