""" This function test if application context is available :param text: String to traduce :return: lazyfied string or string """ try: # Test if context is available, # cf. https://github.com/tracim/tracim/issues/173 context = StackedObjectProxy(name="context") context.translator return ugettext(text) except TypeError: return text lazy_ugettext = lazify(_lazy_ugettext) def get_rq_queue(queue_name: str = 'default') -> Queue: """ :param queue_name: name of queue :return: wanted queue """ from tracim.config.app_cfg import CFG cfg = CFG.get_instance() return Queue(queue_name, connection=Redis( host=cfg.EMAIL_SENDER_REDIS_HOST, port=cfg.EMAIL_SENDER_REDIS_PORT, db=cfg.EMAIL_SENDER_REDIS_DB,
def ugettext(value): """Mark a string for translation. Returns the localized unicode string of value. Mark a string to be localized as follows:: _('This should be in lots of languages') """ if PY3: #pragma: no cover return tg.translator.gettext(value) else: return tg.translator.ugettext(value) lazy_ugettext = lazify(ugettext) def ungettext(singular, plural, n): """Mark a string for translation. Returns the localized unicode string of the pluralized value. This does a plural-forms lookup of a message id. ``singular`` is used as the message id for purposes of lookup in the catalog, while ``n`` is used to determine which plural form to use. The returned message is a Unicode string. Mark a string to be localized as follows:: ungettext('There is %(num)d file here', 'There are %(num)d files here', n) % {'num': n}