def initialize(): """Install a global underscore function for testing purposes.""" # Avoid circular imports. from mailman.core.i18n import initialize as core_initialize strategy = TestingStrategy('mailman-testing') application = registry.register(strategy) core_initialize(application)
def initialize(application=None): """Initialize the i18n subsystem. :param application: An optional `flufl.i18n.Application` instance to use as the translation context. This primarily exists to support the testing environment. :type application: `flufl.i18n.Application` """ global _ if application is None: strategy = PackageStrategy('mailman', mailman.messages) application = registry.register(strategy) _ = application._
def initialize(): """Install a global underscore function for testing purposes.""" strategy = TestingStrategy('mailman-testing') application = registry.register(strategy) core_initialize(application)
import logging from functools import wraps from flufl.i18n import registry from flufl.i18n import PackageStrategy from telegram import Emoji from telegram.ext.dispatcher import run_async import locales from database import db_session from user_setting import UserSetting from shared_vars import gm strategy = PackageStrategy('unobot', locales) application = registry.register(strategy) _ = application._ logger = logging.getLogger(__name__) TIMEOUT = 2.5 def __(string, multi_translate): """Translates text into all locales on the stack""" translations = list() locales = list() if not multi_translate: _.push('en_US') translations.append(_(string)) _.pop()
def build(self): strategy = PackageStrategy('test', translations.messages) application = registry.register(strategy) self._ = application._ self.set_language('fr')
from pathlib import Path from flufl.i18n import registry from constants import LOCALE_NAME, LOCALE_FOLDER class Strategy(object): """Strategy for flufl's translation stuff. Adapted from _BaseStrategy in _strategy of flufl module.""" def __init__(self, name, folder=None): self.name = name if folder is None: self.folder = os.path.dirname(__file__) else: self.folder = str(folder) def __call__(self, language_code=None): languages = (None if language_code is None else [language_code]) try: return gettext.translation( self.name, self.folder, languages) except IOError: return gettext.NullTranslations() strategy = Strategy(LOCALE_NAME, folder=Path(LOCALE_FOLDER)) application = registry.register(strategy) # noinspection PyProtectedMember _ = application._