Skip to content

Commit

Permalink
ext: allow BABEL_DEFAULT_LOCALE overridability
Browse files Browse the repository at this point in the history
  • Loading branch information
zzacharo committed Mar 21, 2024
1 parent 0d05be3 commit 721fc1d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion invenio_i18n/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def init_app(self, app, localeselector=None, timezoneselector=None):
timezone_selector=timezoneselector or get_timezone,
)

app.config["BABEL_DEFAULT_LOCALE"] = "en"
app.config.setdefault("BABEL_DEFAULT_LOCALE", "en")

# Register Jinja2 template filters for date formatting (Flask-Babel
# already installs other filters).
Expand Down
2 changes: 2 additions & 0 deletions tests/test_invenio_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def test_default_lang(app):
i18n = InvenioI18N(app)
with app.app_context():
assert [str(x) for x in i18n.get_locales()] == ["da", "en", "de"]
assert app.config["BABEL_DEFAULT_LOCALE"] == "da"


def test_get_languages(app):
Expand All @@ -78,6 +79,7 @@ def test_get_languages(app):
("en", "engelsk"),
("de", "tysk"),
]
assert app.config["BABEL_DEFAULT_LOCALE"] == "da"


def test_json_provider_class(app):
Expand Down

0 comments on commit 721fc1d

Please sign in to comment.