Coverage for seedboxsync/front/babel.py: 100%
10 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-26 17:46 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-26 17:46 +0000
1#
2# Copyright (C) 2015-2026 Guillaume Kulakowski <guillaume@kulakowski.fr>
3#
4# For the full copyright and license information, please view the LICENSE
5# file that was distributed with this source code.
6#
7"""SeedboxSync front i18n module."""
9from flask import request
10from flask_babel import Babel
11from seedboxsync.core import Config, current_app as app
13babel = Babel()
14ALLOWED_LANGUAGES = ["fr", "en"]
17def get_locale() -> str | None:
18 """
19 Get locale from browser.
21 Returns:
22 str: The local.
23 """
24 locale = app.config.get(Config.CONFIG_NAMESPACE + "WEBUI_LANGUAGE", "auto")
25 if locale != "auto":
26 return str(locale)
27 return request.accept_languages.best_match(ALLOWED_LANGUAGES)