2019-09-08 23:05:43 +02:00
|
|
|
import gettext
|
|
|
|
import config
|
|
|
|
|
|
|
|
|
2019-09-12 15:43:57 +02:00
|
|
|
class Texts:
|
|
|
|
def __init__(self, base: str = 'base'):
|
|
|
|
self.locale = config.locale
|
2019-09-29 18:31:01 +02:00
|
|
|
self.base = base
|
2019-09-12 15:43:57 +02:00
|
|
|
|
|
|
|
def get(self, text: str) -> str:
|
2019-09-29 18:31:01 +02:00
|
|
|
texts = gettext.translation(self.base, localedir='extras/locales',
|
|
|
|
languages=[self.locale])
|
|
|
|
texts.install()
|
|
|
|
return texts.gettext(text)
|
|
|
|
|
|
|
|
def set(self, lang: str):
|
|
|
|
self.locale = lang
|