From e1b6fa25e9cb80bc203245b3daac37215f2c0275 Mon Sep 17 00:00:00 2001 From: haseo Date: Mon, 19 Nov 2018 15:54:28 +0800 Subject: [PATCH] A better solution to #681 --- cps/web.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cps/web.py b/cps/web.py index 396066d9..5541ebcf 100644 --- a/cps/web.py +++ b/cps/web.py @@ -197,12 +197,7 @@ def get_locale(): if user.nickname != 'Guest': # if the account is the guest account bypass the config lang settings return user.locale translations = [item.language for item in babel.list_translations()] + ['en'] - preferred = [x.replace('-', '_') for x in request.accept_languages.values()] - - # In the case of Simplified Chinese, Accept-Language is "zh-CN", while our translation of Simplified Chinese is "zh_Hans_CN". - # TODO: This is Not a good solution, should be improved. - if "zh_CN" in preferred: - return "zh_Hans_CN" + preferred = [str(LC.parse(x, '-')) for x in request.accept_languages.values()] return negotiate_locale(preferred, translations)