64 lines
1.7 KiB
Python
64 lines
1.7 KiB
Python
EXISTING_STRINGS = {
|
|
"kanken_online",
|
|
"options",
|
|
"log_in",
|
|
"register",
|
|
"log_out",
|
|
"kanji",
|
|
"forum",
|
|
"main_page",
|
|
"username",
|
|
"password",
|
|
"search",
|
|
"search_placeholder",
|
|
"include_kanji",
|
|
"include_kotoba"
|
|
}
|
|
|
|
ENGLISH = {
|
|
"kanken_online": "KankenOnline",
|
|
"options": "Options",
|
|
"log_in": "Log in",
|
|
"register": "Register",
|
|
"log_out": "Log out",
|
|
"kanji": "Kanji",
|
|
"forum": "Forum",
|
|
"main_page": "Main Page",
|
|
"username": "Username",
|
|
"password": "Password",
|
|
"search": "Search",
|
|
"search_placeholder": "Enter kanji or word",
|
|
"include_kanji": "Include kanji",
|
|
"include_kotoba": "Include kotoba"
|
|
}
|
|
|
|
JAPANESE = {
|
|
"kanken_online": "漢検オンライン",
|
|
"options": "設定",
|
|
"log_in": "ログイン",
|
|
"register": "登録",
|
|
"log_out": "ログアウト",
|
|
"kanji": "漢字",
|
|
"forum": "掲示板",
|
|
"main_page": "ホームページ",
|
|
"username": "ユーザー名",
|
|
"password": "パスワード",
|
|
"search": "検索",
|
|
"search_placeholder": "漢字・言葉を入力",
|
|
"include_kanji": "漢字を含む",
|
|
"include_kotoba": "言葉を含む",
|
|
}
|
|
|
|
LANGUAGES = [
|
|
ENGLISH,
|
|
JAPANESE
|
|
]
|
|
|
|
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]
|