def set_language_code(code, gettext_install=False):
"""Set the BCP-47 language code that the speech systems should use.
Args:
gettext_install: if True, gettext's _() will be installed in as a builtin.
As this has global effect, it should only be done by applications.
"""
global _language_code
_language_code = code.replace('_', '-')
if gettext_install:
if not _locale_dir:
raise ValueError('locale_dir is not set. Please call set_locale_dir().')
language_id = code.replace('-', '_')
t = gettext.translation(_LOCALE_DOMAIN, _locale_dir, [language_id], fallback=True)
t.install()
评论列表
文章目录