def translations(): """Return a js file that will handle translations so Flask interpolation can be isolated """ domain = Domain() translations = domain.get_translations() template = render_template("js/translations.js", translations=translations._catalog) return Response(response=template, status=200, mimetype=MIMETYPE_APP_JS)
def setUp(self): self.app = Flask(__name__) self.app.register_blueprint(kerko_blueprint, url_prefix='/bibliography') babel_domain = Domain() babel = Babel(default_domain=babel_domain) babel.init_app(self.app) ctx = self.app.app_context() ctx.push()
class Translations: """Fixes WTForms translation support and uses wtforms translations.""" wtforms_domain = Domain(messages_path(), domain="wtforms") def gettext(self, string): return self.wtforms_domain.gettext(string) def ngettext(self, singular, plural, n): return self.wtforms_domain.ngettext(singular, plural, n)
def translation_domain(self): """Return the domain for this plugin's translation_path.""" path = self.translation_path return Domain(path) if path else NullDomain()
def get_i18n_domain(app): return Domain()
def lazy_gettext(string, **variables): return Domain.gettext(string, **variables)
""" Kerko: A Flask blueprint that provides faceted search for bibliographies based on Zotero. """ # pylint: disable=invalid-name import pathlib from flask import Blueprint from flask_babel import Domain from .jinja2 import register_filters babel_domain = Domain(domain='kerko') def init_default_config(state): """ Initialize default KERKO settings in the app's config object. The following settings must be set in the app's config and have no defaults: - `KERKO_ZOTERO_LIBRARY_ID` - `KERKO_ZOTERO_LIBRARY_TYPE` - `KERKO_ZOTERO_API_KEY` - `KERKO_DATA_DIR` The following settings are used with Bootstrap-Flask to load CDN-based resources. Alternatively, one may set `BOOTSTRAP_SERVE_LOCAL=True` to use the static resources included with the Bootstrap-Flask extension (and ignore these settings):
""" Instantiate extensions. Each extension is initialized by the create_app factory of the app module. """ # pylint: disable=invalid-name import pathlib from flask_babel import Babel, Domain from flask_bootstrap import Bootstrap babel_domain = Domain() babel = Babel(default_domain=babel_domain) bootstrap = Bootstrap()
def get_i18n_domain(app): kwargs = { "translation_directories": config_value("I18N_DIRNAME", app=app), "domain": config_value("I18N_DOMAIN", app=app), } return Domain(**kwargs)