From 58735caff38753547d9db38acae765ac4dc6f5ba Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sun, 26 Sep 2021 17:04:53 +0200 Subject: [PATCH] Enhancements for displaying languages on non english locale --- cps/db.py | 15 ++++++++++----- cps/web.py | 14 ++++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/cps/db.py b/cps/db.py index 71f5031b..cfb2ed7c 100644 --- a/cps/db.py +++ b/cps/db.py @@ -805,11 +805,16 @@ class CalibreDB(): .filter(self.common_filters()) \ .group_by(text('books_languages_link.lang_code')).all() for lang in languages: - try: - cur_l = LC.parse(lang.lang_code) - lang.name = cur_l.get_language_name(get_locale()) - except UnknownLocaleError: - lang.name = _(isoLanguages.get(part3=lang.lang_code).name) + lang.name = isoLanguages.get_language_name(get_locale(), lang.lang_code) + #try: + # if lang.lang_code.lower() == "und": + # lang.name = isoLanguages.get_language_name(get_locale(), lang.lang_code) + # # lang.name = _("Undetermined") + # else: + # cur_l = LC.parse(lang.lang_code) + # lang.name = cur_l.get_language_name(get_locale()) + #except UnknownLocaleError: + # lang.name = _(isoLanguages.get(part3=lang.lang_code).name) return languages def update_title_sort(self, config, conn=None): diff --git a/cps/web.py b/cps/web.py index 9dcb6541..44fb6b92 100644 --- a/cps/web.py +++ b/cps/web.py @@ -1745,12 +1745,14 @@ def show_book(book_id): entries = calibre_db.get_filtered_book(book_id, allow_show_archived=True) if entries: for index in range(0, len(entries.languages)): - try: - entries.languages[index].language_name = LC.parse(entries.languages[index].lang_code)\ - .get_language_name(get_locale()) - except UnknownLocaleError: - entries.languages[index].language_name = _( - isoLanguages.get(part3=entries.languages[index].lang_code).name) + entries.languages[index].language_name = isoLanguages.get_language_name(get_locale(), entries.languages[ + index].lang_code) + #try: + # entries.languages[index].language_name = isoLanguages.get_language_name(get_locale(), LC.parse(entries.languages[index].lang_code) + # .get_language_name(get_locale()) + #except UnknownLocaleError: + # entries.languages[index].language_name = _( + # isoLanguages.get(part3=entries.languages[index].lang_code).name) cc = get_cc_columns(filter_config_custom_read=True) book_in_shelfs = [] shelfs = ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == book_id).all()