Python babel 模块,support() 实例源码
我们从Python开源项目中,提取了以下22个代码示例,用于说明如何使用babel.support()。
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, 'wtforms_translations', None)
if translations is None:
dirname = messages_path()
translations = support.Translations.load(
dirname, [get_locale()], domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def _get_translations():
"""Returns the correct gettext translations.
copy from flask-babel with some modifications.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
# babel should be in extensions for get_locale
if 'babel' not in ctx.app.extensions:
return None
translations = getattr(ctx, domain='wtforms'
)
ctx.wtforms_translations = translations
return translations
def get_translations():
"""Returns the correct gettext translations that should be used for
this request. This will never fail and return a dummy translation
object if used outside of the request or if a translation cannot be
found.
"""
ctx = _request_ctx_stack.top
if ctx is None:
return None
translations = getattr(ctx, 'babel_translations', None)
if translations is None:
dirname = os.path.join(ctx.app.root_path, 'translations')
translations = support.Translations.load(dirname, [get_locale()])
ctx.babel_translations = translations
return translations
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。