test(i18n): add comprehensive tests and documentation for i18n system
- Add 45 tests covering translation files, translate(), Accept-Language parsing, language detection, l10n formatters, and API endpoints - Create InternationalizationGuide.md documentation - Fix linting issues (E741, PLW2901) Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
+2
-2
@@ -24,7 +24,7 @@ from app.utils.i18n import (
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
router = APIRouter(prefix="/api/i18n", tags=["i18n"])
|
||||
router = APIRouter(prefix="/i18n", tags=["i18n"])
|
||||
|
||||
|
||||
class LanguageInfo(BaseModel):
|
||||
@@ -103,7 +103,7 @@ async def set_language(
|
||||
_persist_language_to_profile(request, db, lang)
|
||||
|
||||
language_name = next(
|
||||
(l["native"] for l in SUPPORTED_LANGUAGES if l["code"] == lang),
|
||||
(entry["native"] for entry in SUPPORTED_LANGUAGES if entry["code"] == lang),
|
||||
lang,
|
||||
)
|
||||
logger.info("Language preference set to '%s'", lang)
|
||||
|
||||
+2
-2
@@ -225,8 +225,8 @@ def _parse_accept_language(header: str) -> str | None:
|
||||
return None
|
||||
|
||||
entries: list[tuple[float, str]] = []
|
||||
for part in header.split(","):
|
||||
part = part.strip()
|
||||
for raw_part in header.split(","):
|
||||
part = raw_part.strip()
|
||||
if not part:
|
||||
continue
|
||||
if ";q=" in part:
|
||||
|
||||
Reference in New Issue
Block a user