Fixes for use gettext in paramecio, deprecating old language system

This commit is contained in:
absurdo 2023-12-17 22:16:09 +01:00
parent fc15bd74bb
commit 2ba2ac6d37
11 changed files with 66 additions and 34 deletions

View file

@ -1,9 +1,11 @@
#!/usr/bin/env python3
from importlib import import_module
import gettext
#from paramecio.citoplasma.sessions import get_session
import json
from flask import session, has_request_context
import os
yes_session=False
@ -28,6 +30,15 @@ def load_lang(*args):
# here load the language
def pgettext(module_file):
module=os.path.dirname(os.path.realpath(module_file))
base_name=os.path.dirname(os.path.realpath(module))
l=gettext.translation(os.path.basename(base_name), module+'/languages/', languages=I18n.dict_i18n, fallback=True)
return l.gettext
class I18n:
"""Class for i18n tasks