def mock_translations(monkeypatch, request_context): domain = get_domain() locales = { 'fr_FR': ('French', 'France'), 'en_GB': ('English', 'United Kingdom') } monkeypatch.setattr('indico.util.i18n.get_all_locales', lambda: locales) monkeypatch.setattr(domain, 'get_translations', MockTranslations)
def get_translation_domain(plugin_name=_use_context): """Get the translation domain for the given plugin. If `plugin_name` is omitted, the plugin will be taken from current_plugin. If `plugin_name` is None, the core translation domain ('indico') will be used. """ if plugin_name is None: return get_domain() else: plugin = None if has_app_context(): from indico.core.plugins import plugin_engine plugin = plugin_engine.get_plugin(plugin_name) if plugin_name is not _use_context else current_plugin if plugin: return plugin.translation_domain else: return get_domain()