mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-07 11:23:40 +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
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
# a mapping between absolute .mo file path and Translation object
|
||||||
|
_translations = {}
|
||||||
|
_unspecified = ["unspecified"]
|
||||||
|
|
||||||
|
|
||||||
def _translation(
|
def _translation(
|
||||||
domain,
|
domain,
|
||||||
localedir=None,
|
localedir=None,
|
||||||
languages=None,
|
languages=None,
|
||||||
class_=None,
|
class_=None,
|
||||||
fallback=False,
|
fallback=False,
|
||||||
codeset=gettext._unspecified,
|
codeset=_unspecified,
|
||||||
):
|
):
|
||||||
if class_ is None:
|
if class_ is None:
|
||||||
class_ = gettext.GNUTranslations
|
class_ = gettext.GNUTranslations
|
||||||
@ -123,10 +128,10 @@ def _translation(
|
|||||||
result = None
|
result = None
|
||||||
for mofile in mofiles:
|
for mofile in mofiles:
|
||||||
key = (class_, os.path.abspath(mofile))
|
key = (class_, os.path.abspath(mofile))
|
||||||
t = gettext._translations.get(key)
|
t = _translations.get(key)
|
||||||
if t is None:
|
if t is None:
|
||||||
with open(mofile, "rb") as fp:
|
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
|
# Copy the translation object to allow setting fallbacks and
|
||||||
# output charset. All other instance data is shared with the
|
# output charset. All other instance data is shared with the
|
||||||
# cached object.
|
# cached object.
|
||||||
@ -135,7 +140,7 @@ def _translation(
|
|||||||
import copy
|
import copy
|
||||||
|
|
||||||
t = copy.copy(t)
|
t = copy.copy(t)
|
||||||
if codeset is not gettext._unspecified:
|
if codeset is not _unspecified:
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
warnings.warn("parameter codeset is deprecated", DeprecationWarning, 2)
|
warnings.warn("parameter codeset is deprecated", DeprecationWarning, 2)
|
||||||
|
Loading…
Reference in New Issue
Block a user