mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-01 00:03:29 +00:00
fix(i18n): Fix read i18n config error (#2368)
This commit is contained in:
parent
96bcb6d138
commit
fb36948383
@ -101,13 +101,18 @@ def _find(domain, localedir=None, languages=None, all=False):
|
||||
return result
|
||||
|
||||
|
||||
# a mapping between absolute .mo file path and Translation object
|
||||
_translations = {}
|
||||
_unspecified = ["unspecified"]
|
||||
|
||||
|
||||
def _translation(
|
||||
domain,
|
||||
localedir=None,
|
||||
languages=None,
|
||||
class_=None,
|
||||
fallback=False,
|
||||
codeset=gettext._unspecified,
|
||||
codeset=_unspecified,
|
||||
):
|
||||
if class_ is None:
|
||||
class_ = gettext.GNUTranslations
|
||||
@ -123,10 +128,10 @@ def _translation(
|
||||
result = None
|
||||
for mofile in mofiles:
|
||||
key = (class_, os.path.abspath(mofile))
|
||||
t = gettext._translations.get(key)
|
||||
t = _translations.get(key)
|
||||
if t is None:
|
||||
with open(mofile, "rb") as fp:
|
||||
t = gettext._translations.setdefault(key, class_(fp))
|
||||
t = _translations.setdefault(key, class_(fp))
|
||||
# Copy the translation object to allow setting fallbacks and
|
||||
# output charset. All other instance data is shared with the
|
||||
# cached object.
|
||||
@ -135,7 +140,7 @@ def _translation(
|
||||
import copy
|
||||
|
||||
t = copy.copy(t)
|
||||
if codeset is not gettext._unspecified:
|
||||
if codeset is not _unspecified:
|
||||
import warnings
|
||||
|
||||
warnings.warn("parameter codeset is deprecated", DeprecationWarning, 2)
|
||||
|
Loading…
Reference in New Issue
Block a user