Settings menu was not translated

This commit is contained in:
Yohann D'ANELLO
2020-11-27 22:19:41 +01:00
parent f07324662a
commit d2d74c97a4
8 changed files with 134 additions and 29 deletions

View File

@ -7,6 +7,7 @@ import os
from typing import Any, Generator
from .resources import ResourceManager
from .translations import gettext as _
class Settings:
@ -17,26 +18,17 @@ class Settings:
We can define the setting by simply use settings.TEXTURE_PACK = 'new_key'
"""
def __init__(self):
self.KEY_UP_PRIMARY = \
['z', 'Touche principale pour aller vers le haut']
self.KEY_UP_SECONDARY = \
['KEY_UP', 'Touche secondaire pour aller vers le haut']
self.KEY_DOWN_PRIMARY = \
['s', 'Touche principale pour aller vers le bas']
self.KEY_DOWN_SECONDARY = \
['KEY_DOWN', 'Touche secondaire pour aller vers le bas']
self.KEY_LEFT_PRIMARY = \
['q', 'Touche principale pour aller vers la gauche']
self.KEY_LEFT_SECONDARY = \
['KEY_LEFT', 'Touche secondaire pour aller vers la gauche']
self.KEY_RIGHT_PRIMARY = \
['d', 'Touche principale pour aller vers la droite']
self.KEY_RIGHT_SECONDARY = \
['KEY_RIGHT', 'Touche secondaire pour aller vers la droite']
self.KEY_ENTER = \
['\n', 'Touche pour valider un menu']
self.TEXTURE_PACK = ['ascii', 'Pack de textures utilisé']
self.LOCALE = [locale.getlocale()[0][:2], 'Langue']
self.KEY_UP_PRIMARY = ['z', 'Main key to move up']
self.KEY_UP_SECONDARY = ['KEY_UP', 'Secondary key to move up']
self.KEY_DOWN_PRIMARY = ['s', 'Main key to move down']
self.KEY_DOWN_SECONDARY = ['KEY_DOWN', 'Secondary key to move down']
self.KEY_LEFT_PRIMARY = ['q', 'Main key to move left']
self.KEY_LEFT_SECONDARY = ['KEY_LEFT', 'Secondary key to move left']
self.KEY_RIGHT_PRIMARY = ['d', 'Main key to move right']
self.KEY_RIGHT_SECONDARY = ['KEY_RIGHT', 'Secondary key to move right']
self.KEY_ENTER = ['\n', 'Key to validate a menu']
self.TEXTURE_PACK = ['ascii', 'Texture pack']
self.LOCALE = [locale.getlocale()[0][:2], 'Language']
def __getattribute__(self, item: str) -> Any:
superattribute = super().__getattribute__(item)
@ -55,10 +47,10 @@ class Settings:
Retrieve the comment of a setting.
"""
if item in self.settings_keys:
return object.__getattribute__(self, item)[1]
return _(object.__getattribute__(self, item)[1])
for key in self.settings_keys:
if getattr(self, key) == item:
return object.__getattribute__(self, key)[1]
return _(object.__getattribute__(self, key)[1])
@property
def settings_keys(self) -> Generator[str, Any, None]: