KankenOnline/kanken_online/lang.py

91 lines
3.8 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",
2024-10-14 11:46:16 +00:00
"kanji",
"forum",
2024-10-14 11:02:11 +00:00
"main_page",
"username",
2024-10-14 11:13:26 +00:00
"password",
"search",
2024-10-14 11:46:16 +00:00
"search_placeholder",
"include_kanji",
2024-10-14 11:52:07 +00:00
"include_kotoba",
"username_required",
2024-10-14 15:20:28 +00:00
"password_required",
"incorrect_username",
"incorrect_password"
"about",
2024-10-14 15:34:31 +00:00
"about-para",
"indices"
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",
2024-10-14 11:46:16 +00:00
"search_placeholder": "Enter kanji or word",
"include_kanji": "Include kanji",
2024-10-14 11:52:07 +00:00
"include_kotoba": "Include kotoba",
"username_required": "Username required.",
"password_required": "Password required.",
"incorrect_username": "Incorrect username.",
2024-10-14 15:20:28 +00:00
"incorrect_password": "Incorrect password.",
"about": "About KankenOnline",
2024-10-14 15:34:31 +00:00
"about-para": "KankenOnline is a website seeking to provide resources to pass the Kanji Kentei level 1 exam. You can search through the approximately 6,300 characters included in Kanken, as well as generate a number of study materials automatically. For example, you can generate a PDF-format exam resembling the Kanken level 1 exam, which has the goal of mirroring the real thing as closely as possible for your preparation. Additionally, a variety of information about kanji is provided, among which phonetic series, rimes/kanji phonology, radicals, inseparable kanji, character origins and etymologies.",
"indices": "Indices",
"radical_index": "Radical index",
"indivisible_index": "Indivisible kanji index",
"phonetic_series": "Phonetic series",
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": "検索",
2024-10-14 11:46:16 +00:00
"search_placeholder": "漢字・言葉を入力",
"include_kanji": "漢字を含む",
"include_kotoba": "言葉を含む",
2024-10-14 11:52:07 +00:00
"username_required": "ユーザー名が必要です",
"password_required": "パスワードが必要です",
"incorrect_username": "ユーザー名が違います",
2024-10-14 15:20:28 +00:00
"incorrect_password": "パスワードが違います",
"about": "漢検オンラインとは",
2024-10-14 15:34:31 +00:00
"about-para": "漢検オンラインとは、漢検一級合格を目当てにした資料を供用しているサイトです。ここで漢検のやく字を検索でき、いろんな勉強材を自動的に作ることができます。たとえば、漢検一級模様の試験PDFを作ることができて、本物の漢検試験に大抵該当することが目的です。さらに、色々漢字についての情報を取り集めております。諧声域かいせいいき・音韻学・部首・不可分漢字・字源・語源などがその内です。",
"indices": "索引",
"radical_index": "部首索引",
"indivisible_index": "不可分漢字索引",
"phonetic_series": "諧声域索引",
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
# assert not [key for lang in LANGUAGES for key in lang if ((key in lang) and (key not in EXISTING_STRINGS))]
2024-10-14 11:46:16 +00:00
# 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
2024-10-14 10:49:16 +00:00
def localize(text_id: str, language: dict[str, str]) -> str:
return language[text_id]