From 2100a324dfac0697e4da3bfb2e9df1fbcfeb3ed1 Mon Sep 17 00:00:00 2001 From: Kiril Kovachev Date: Mon, 14 Oct 2024 12:46:16 +0100 Subject: [PATCH] Localize search --- kanken_online/lang.py | 17 ++++++++++++++--- kanken_online/templates/search/search.html | 6 +++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/kanken_online/lang.py b/kanken_online/lang.py index d09b922..b99beb2 100644 --- a/kanken_online/lang.py +++ b/kanken_online/lang.py @@ -4,11 +4,15 @@ EXISTING_STRINGS = { "log_in", "register", "log_out", + "kanji", + "forum", "main_page", "username", "password", "search", - "search_placeholder" + "search_placeholder", + "include_kanji", + "include_kotoba" } ENGLISH = { @@ -23,7 +27,9 @@ ENGLISH = { "username": "Username", "password": "Password", "search": "Search", - "search_placeholder": "Enter kanji or word" + "search_placeholder": "Enter kanji or word", + "include_kanji": "Include kanji", + "include_kotoba": "Include kotoba" } JAPANESE = { @@ -38,7 +44,9 @@ JAPANESE = { "username": "ユーザー名", "password": "パスワード", "search": "検索", - "search_placeholder": "漢字・言葉を入力" + "search_placeholder": "漢字・言葉を入力", + "include_kanji": "漢字を含む", + "include_kotoba": "言葉を含む", } LANGUAGES = [ @@ -47,6 +55,9 @@ LANGUAGES = [ ] assert all(all(key in lang for key in EXISTING_STRINGS) for lang in LANGUAGES) # Ensure all strings are mapped for all existing languages +assert not [key for lang in LANGUAGES for key in lang if ((key in lang) and (key not in EXISTING_STRINGS))] +# assert not any((((key in lang) and (key not in EXISTING_STRINGS)) for key in lang) for lang in LANGUAGES) # Ensure no languages have strings not specified by the main index + def localize(text_id: str, language: dict[str, str]) -> str: return language[text_id] diff --git a/kanken_online/templates/search/search.html b/kanken_online/templates/search/search.html index c0aae21..c7ec867 100644 --- a/kanken_online/templates/search/search.html +++ b/kanken_online/templates/search/search.html @@ -6,11 +6,11 @@ {% block content %}
- + - + - +
{% block results %}