|
|
@ -6,6 +6,7 @@ |
|
|
|
# --------------------------------------------------------------------------------------------------------- |
|
|
|
import utils.config_tool |
|
|
|
import utils.path_const as P |
|
|
|
import basic.constants as B |
|
|
|
import basic.program |
|
|
|
|
|
|
|
DEFAULT_LANGUAGE = "en" |
|
|
@ -39,18 +40,12 @@ class I18n: |
|
|
|
def getText(self, key, job=None): |
|
|
|
""" |
|
|
|
this function gets the text depending on language which is set in job.conf |
|
|
|
:param domain: |
|
|
|
:param key: |
|
|
|
:param key: MUST GIVEN WITH (f"{CONST=}", .. |
|
|
|
:return: |
|
|
|
if not (isinstance(langue, str) and len(langue)): |
|
|
|
raise Exception(EXP_KEY_MISSING, (domain, key)) |
|
|
|
if not (isinstance(key, str) and len(key)): |
|
|
|
raise Exception(EXP_KEY_MISSING, (langue, key)) |
|
|
|
|
|
|
|
return self.cache[langue][key] |
|
|
|
return self.cache[language][key] |
|
|
|
""" |
|
|
|
if job is None: |
|
|
|
jon = basic.program.Job.getInstance() |
|
|
|
job = basic.program.Job.getInstance() |
|
|
|
language = job.conf.confs["language"] |
|
|
|
if language not in self.cache: |
|
|
|
raise Exception(EXP_KEY_MISSING, (key)) |
|
|
@ -67,8 +62,11 @@ class I18n: |
|
|
|
if job is None: |
|
|
|
jon = basic.program.Job.getInstance() |
|
|
|
out = [] |
|
|
|
out.append(self.extractText(key)) |
|
|
|
key = self.extractKey(key) |
|
|
|
for language in self.cache: |
|
|
|
if key not in self.cache[language]: |
|
|
|
continue |
|
|
|
out.append(self.cache[language][key]) |
|
|
|
return out |
|
|
|
|
|
|
|