mirror of
https://github.com/PaiGramTeam/FixMiYouShe.git
synced 2024-09-28 05:05:01 +00:00
🌐 use 2-letter ISO language code
This commit is contained in:
parent
12bd0587f6
commit
e254241302
@ -19,6 +19,23 @@ class I18nLang(str, Enum):
|
||||
VI_VN = "vi-vn"
|
||||
|
||||
|
||||
i18n_alias = {
|
||||
"zh": I18nLang.ZH_CN,
|
||||
"tw": I18nLang.ZH_TW,
|
||||
"de": I18nLang.DE_DE,
|
||||
"en": I18nLang.EN_US,
|
||||
"es": I18nLang.ES_ES,
|
||||
"fr": I18nLang.FR_FR,
|
||||
"id": I18nLang.ID_ID,
|
||||
"it": I18nLang.IT_IT,
|
||||
"ja": I18nLang.JA_JP,
|
||||
"ko": I18nLang.KO_KR,
|
||||
"pt": I18nLang.PT_PT,
|
||||
"ru": I18nLang.RU_RU,
|
||||
"th": I18nLang.TH_TH,
|
||||
"tr": I18nLang.TR_TR,
|
||||
"vi": I18nLang.VI_VN,
|
||||
}
|
||||
i18n_map = {
|
||||
I18nLang.ZH_CN: {
|
||||
"view": "查看原文",
|
||||
|
@ -2,7 +2,7 @@ import json
|
||||
from typing import Dict, List, Callable
|
||||
|
||||
from src.api.hoyolab import Hoyolab
|
||||
from src.api.i18n import I18n
|
||||
from src.api.i18n import I18n, i18n_alias
|
||||
from src.api.models import PostRecommend, PostType, PostInfo
|
||||
from src.env import HOYOLAB
|
||||
from src.log import logger
|
||||
@ -55,7 +55,9 @@ async def process_article_video(
|
||||
|
||||
async def process_article(post_id: int, lang: str) -> str:
|
||||
try:
|
||||
i18n = I18n(lang)
|
||||
i18n = I18n(i18n_alias.get(lang))
|
||||
if not i18n:
|
||||
i18n = I18n(lang)
|
||||
except ValueError:
|
||||
i18n = I18n()
|
||||
async with Hoyolab() as hoyolab:
|
||||
|
Loading…
Reference in New Issue
Block a user