1
0
mirror of https://github.com/janeczku/calibre-web synced 2025-11-16 06:57:12 +00:00

add default language configuration

This commit is contained in:
idalin
2017-01-09 13:47:50 +08:00
parent 571bec6363
commit 9f65eae024
3 changed files with 12 additions and 3 deletions

View File

@@ -165,7 +165,8 @@ LANGUAGES = {
'en': 'English',
'de': 'Deutsch',
'fr': 'Français',
'es': 'Español'
'es': 'Español',
'zh_Hans_CN': '简体中文'
}
@@ -173,9 +174,14 @@ LANGUAGES = {
def get_locale():
# if a user is logged in, use the locale from the user settings
user = getattr(g, 'user', None)
translations = babel.list_translations() + [LC('en')]
if user is not None and hasattr(user, "locale"):
if user.locale == 'zh':
return 'zh_Hans_CN'
return user.locale
preferred = [x.replace('-', '_') for x in request.accept_languages.values()]
if config.DEFAULT_LANG:
return config.DEFAULT_LANG
return negotiate_locale(preferred, LANGUAGES.keys())