fix(i18n): validate Accept-Language header against registered locales

This commit is contained in:
ghostubborn committed 2026-04-02 14:20:15 +08:00
1 parent 2421010fe1
commit f2404903d6
1 file changed
+2 -1
+2 -1
View File
@@ -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')