From 65af8c8e188ab358fa46e8c2a44fe6f2151bc2df Mon Sep 17 00:00:00 2001 From: ChinoUkaegbu <77782533+ChinoUkaegbu@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:14:44 +0400 Subject: [PATCH 1/6] add current language to topbar in alert.html --- openlibrary/templates/site/alert.html | 1 + 1 file changed, 1 insertion(+) diff --git a/openlibrary/templates/site/alert.html b/openlibrary/templates/site/alert.html index e18d7b1ad2f..bea16b48d22 100644 --- a/openlibrary/templates/site/alert.html +++ b/openlibrary/templates/site/alert.html @@ -9,6 +9,7 @@
+ $(get_lang() or 'en') $_('Change Website Language')
From 9c657f44b51ab9990967c5db58c63a6e6ff80ebf Mon Sep 17 00:00:00 2001 From: ChinoUkaegbu <77782533+ChinoUkaegbu@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:08:48 +0100 Subject: [PATCH 2/6] add language dictionary to code.py --- openlibrary/plugins/openlibrary/code.py | 56 +++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/openlibrary/plugins/openlibrary/code.py b/openlibrary/plugins/openlibrary/code.py index 8ece430c8cd..72549228f11 100644 --- a/openlibrary/plugins/openlibrary/code.py +++ b/openlibrary/plugins/openlibrary/code.py @@ -1243,6 +1243,61 @@ def setup_template_globals(): get_cover_url, ) + SUPPORTED_LANGUAGES = { + "cs": { + "localized": 'Czech', + "native": "Čeština" + }, + "de": { + "localized": 'German', + "native": "Deutsch" + }, + "en": { + "localized": 'English', + "native": "English" + }, + "es": { + "localized": 'Spanish', + "native": "Español" + }, + "fr": { + "localized": 'French', + "native": "Français" + }, + "hr": { + "localized": 'Croatian', + "native": "Hrvatski" + }, + "it": { + "localized": 'Italian', + "native": "Italiano" + }, + "pt": { + "localized": 'Portuguese', + "native": "Português" + }, + "hi": { + "localized": 'Hindi', + "native": "हिंदी" + }, + "sc": { + "localized": 'Sardinian', + "native": "Sardu" + }, + "te": { + "localized": 'Telugu', + "native": "తెలుగు" + }, + "uk": { + "localized": 'Ukrainian', + "native": "Українська" + }, + "zh": { + "localized": 'Chinese', + "native": "中文" + } + } + web.template.Template.globals.update( { 'cookies': web.cookies, @@ -1258,6 +1313,7 @@ def setup_template_globals(): 'random': random.Random(), 'choose_random_from': random.choice, 'get_lang': lambda: web.ctx.lang, + 'supported_langs': SUPPORTED_LANGUAGES, 'ceil': math.ceil, 'get_best_edition': get_best_edition, 'get_book_provider': get_book_provider, From 168d9e30324946dab46e72f73514bcfd5db015cb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 08:09:34 +0000 Subject: [PATCH 3/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- openlibrary/plugins/openlibrary/code.py | 65 +++++-------------------- 1 file changed, 13 insertions(+), 52 deletions(-) diff --git a/openlibrary/plugins/openlibrary/code.py b/openlibrary/plugins/openlibrary/code.py index 72549228f11..8d10424ef89 100644 --- a/openlibrary/plugins/openlibrary/code.py +++ b/openlibrary/plugins/openlibrary/code.py @@ -1244,58 +1244,19 @@ def setup_template_globals(): ) SUPPORTED_LANGUAGES = { - "cs": { - "localized": 'Czech', - "native": "Čeština" - }, - "de": { - "localized": 'German', - "native": "Deutsch" - }, - "en": { - "localized": 'English', - "native": "English" - }, - "es": { - "localized": 'Spanish', - "native": "Español" - }, - "fr": { - "localized": 'French', - "native": "Français" - }, - "hr": { - "localized": 'Croatian', - "native": "Hrvatski" - }, - "it": { - "localized": 'Italian', - "native": "Italiano" - }, - "pt": { - "localized": 'Portuguese', - "native": "Português" - }, - "hi": { - "localized": 'Hindi', - "native": "हिंदी" - }, - "sc": { - "localized": 'Sardinian', - "native": "Sardu" - }, - "te": { - "localized": 'Telugu', - "native": "తెలుగు" - }, - "uk": { - "localized": 'Ukrainian', - "native": "Українська" - }, - "zh": { - "localized": 'Chinese', - "native": "中文" - } + "cs": {"localized": 'Czech', "native": "Čeština"}, + "de": {"localized": 'German', "native": "Deutsch"}, + "en": {"localized": 'English', "native": "English"}, + "es": {"localized": 'Spanish', "native": "Español"}, + "fr": {"localized": 'French', "native": "Français"}, + "hr": {"localized": 'Croatian', "native": "Hrvatski"}, + "it": {"localized": 'Italian', "native": "Italiano"}, + "pt": {"localized": 'Portuguese', "native": "Português"}, + "hi": {"localized": 'Hindi', "native": "हिंदी"}, + "sc": {"localized": 'Sardinian', "native": "Sardu"}, + "te": {"localized": 'Telugu', "native": "తెలుగు"}, + "uk": {"localized": 'Ukrainian', "native": "Українська"}, + "zh": {"localized": 'Chinese', "native": "中文"}, } web.template.Template.globals.update( From 706c4c9e3b9fc24951b96c412ad01f93003f8235 Mon Sep 17 00:00:00 2001 From: ChinoUkaegbu <77782533+ChinoUkaegbu@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:15:44 +0100 Subject: [PATCH 4/6] display language - native and abbreviation - in topbar in alert.html --- openlibrary/templates/site/alert.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlibrary/templates/site/alert.html b/openlibrary/templates/site/alert.html index bea16b48d22..3415a40e4f7 100644 --- a/openlibrary/templates/site/alert.html +++ b/openlibrary/templates/site/alert.html @@ -9,7 +9,7 @@
- $(get_lang() or 'en') + $(supported_langs[get_lang() or 'en']['native']) ($(get_lang() or 'en')) $_('Change Website Language')
From 66d6f478fd0b3f6f9aaf7c9c637fcfee4db0b40b Mon Sep 17 00:00:00 2001 From: ChinoUkaegbu <77782533+ChinoUkaegbu@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:17:03 +0100 Subject: [PATCH 5/6] add border around language component --- static/css/components/language.less | 3 +++ 1 file changed, 3 insertions(+) diff --git a/static/css/components/language.less b/static/css/components/language.less index 548e4a1705c..49f2997f892 100644 --- a/static/css/components/language.less +++ b/static/css/components/language.less @@ -49,6 +49,9 @@ .iaBar .language-component { position: relative; display: block; + border: 1px solid #999; + border-radius: 5px; + padding: .2rem .4rem; // stylelint-disable selector-max-specificity, max-nesting-depth .language-dropdown-component { position: absolute; From 806851606552d31776faa76efd8dae7dd6027d5f Mon Sep 17 00:00:00 2001 From: Mek Date: Wed, 18 Sep 2024 07:28:33 -0700 Subject: [PATCH 6/6] fix css hex refs to use colors.less --- static/css/components/language.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/css/components/language.less b/static/css/components/language.less index 49f2997f892..5c3767c0964 100644 --- a/static/css/components/language.less +++ b/static/css/components/language.less @@ -49,7 +49,7 @@ .iaBar .language-component { position: relative; display: block; - border: 1px solid #999; + border: 1px solid @mid-grey; border-radius: 5px; padding: .2rem .4rem; // stylelint-disable selector-max-specificity, max-nesting-depth