KankenOnline/kanken_online/lang.py
2024-10-14 12:02:11 +01:00

47 lines
1.0 KiB
Python

EXISTING_STRINGS = {
"kanken_online",
"options",
"log_in",
"register",
"log_out",
"main_page",
"username",
"password"
}
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"
}
JAPANESE = {
"kanken_online": "漢検オンライン",
"options": "設定",
"log_in": "ログイン",
"register": "登録",
"log_out": "ログアウト",
"kanji": "漢字",
"forum": "掲示板",
"main_page": "ホームページ",
"username": "ユーザー名",
"password": "パスワード"
}
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]