diff --git a/backend/app/utils/locale.py b/backend/app/utils/locale.py index 868c4f0b..23d04aa9 100644 --- a/backend/app/utils/locale.py +++ b/backend/app/utils/locale.py @@ -27,7 +27,8 @@ def set_locale(locale: str): def get_locale() -> str: if has_request_context(): - return request.headers.get('Accept-Language', 'zh') + raw = request.headers.get('Accept-Language', 'zh') + return raw if raw in _translations else 'zh' return getattr(_thread_local, 'locale', 'zh')