KankenOnline/kanken_online/lang.py

53 lines
1.2 KiB
Python
Raw Normal View History

2024-10-14 10:49:16 +00:00
EXISTING_STRINGS = {
"kanken_online",
"options",
"log_in",
"register",
2024-10-14 11:02:11 +00:00
"log_out",
"main_page",
"username",
2024-10-14 11:13:26 +00:00
"password",
"search",
"search_placeholder"
2024-10-14 10:49:16 +00:00
}
ENGLISH = {
"kanken_online": "KankenOnline",
"options": "Options",
"log_in": "Log in",
"register": "Register",
"log_out": "Log out",
2024-10-14 10:54:26 +00:00
"kanji": "Kanji",
2024-10-14 11:02:11 +00:00
"forum": "Forum",
"main_page": "Main Page",
"username": "Username",
2024-10-14 11:10:37 +00:00
"password": "Password",
2024-10-14 11:13:26 +00:00
"search": "Search",
"search_placeholder": "Enter kanji or word"
2024-10-14 10:49:16 +00:00
}
JAPANESE = {
"kanken_online": "漢検オンライン",
"options": "設定",
"log_in": "ログイン",
"register": "登録",
"log_out": "ログアウト",
2024-10-14 10:54:26 +00:00
"kanji": "漢字",
2024-10-14 11:02:11 +00:00
"forum": "掲示板",
"main_page": "ホームページ",
"username": "ユーザー名",
2024-10-14 11:13:26 +00:00
"password": "パスワード",
"search": "検索",
"search_placeholder": "漢字・言葉を入力"
2024-10-14 10:49:16 +00:00
}
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
def localize(text_id: str, language: dict[str, str]) -> str:
return language[text_id]