mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-29 19:40:31 +00:00
Merge remote-tracking branch 'loglevel/handle_regions_in_locales' into Develop
This commit is contained in:
commit
1ca1ac973a
@ -49,15 +49,24 @@ except ImportError:
|
||||
|
||||
|
||||
def get_language_names(locale):
|
||||
return _LANGUAGE_NAMES.get(str(locale))
|
||||
names = _LANGUAGE_NAMES.get(str(locale))
|
||||
if names is None:
|
||||
names = _LANGUAGE_NAMES.get(locale.language)
|
||||
return names
|
||||
|
||||
|
||||
def get_language_name(locale, lang_code):
|
||||
try:
|
||||
return get_language_names(locale)[lang_code]
|
||||
except KeyError:
|
||||
log.error('Missing translation for language name: {}'.format(lang_code))
|
||||
return "Unknown"
|
||||
UNKNOWN_TRANSLATION = "Unknown"
|
||||
names = get_language_names(locale)
|
||||
if names is None:
|
||||
log.error(f"Missing language names for locale: {str(locale)}/{locale.language}")
|
||||
return UNKNOWN_TRANSLATION
|
||||
|
||||
name = names.get(lang_code, UNKNOWN_TRANSLATION)
|
||||
if name == UNKNOWN_TRANSLATION:
|
||||
log.error("Missing translation for language name: {}".format(lang_code))
|
||||
|
||||
return name
|
||||
|
||||
|
||||
def get_language_codes(locale, language_names, remainder=None):
|
||||
|
Loading…
Reference in New Issue
Block a user