Localize search
This commit is contained in:
parent
45c263602b
commit
2100a324df
@ -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]
|
||||
|
@ -6,11 +6,11 @@
|
||||
|
||||
{% block content %}
|
||||
<form method="get">
|
||||
<label for="search_bar">Search</label>
|
||||
<label for="search_bar">{{ localize("search") }}</label>
|
||||
<input type="text" id="search_bar" name="keywords" placeholder="{{ localize("search_placeholder") }}" value="{{value}}">
|
||||
<label for="include_kanji">Include kanji</label>
|
||||
<label for="include_kanji">{{ localize("include_kanji") }}</label>
|
||||
<input type="checkbox" id="include_kanji" checked>
|
||||
<label for="include_kanji">Include kotoba</label>
|
||||
<label for="include_kanji">{{ localize("include_kotoba") }}</label>
|
||||
<input type="checkbox" id="include_kanji" checked>
|
||||
</form>
|
||||
{% block results %}
|
||||
|
Loading…
Reference in New Issue
Block a user