From 03645f11289f2f4749977b5bb985b2d2daa208f5 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 24 Jul 2026 13:49:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20i18n=E5=A4=9A=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E6=94=AF=E6=8C=81(zh/en/jp/ko)+i18n=5Fgetmsgs=E7=AB=AF?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/load_path.py | 1 + wwwroot/i18n/en/i18n.json | 12 ++++++++++++ wwwroot/i18n/jp/i18n.json | 12 ++++++++++++ wwwroot/i18n/ko/i18n.json | 12 ++++++++++++ wwwroot/i18n/zh/i18n.json | 12 ++++++++++++ wwwroot/i18n_getmsgs.dspy | 13 +++++++++++++ 6 files changed, 62 insertions(+) create mode 100644 wwwroot/i18n/en/i18n.json create mode 100644 wwwroot/i18n/jp/i18n.json create mode 100644 wwwroot/i18n/ko/i18n.json create mode 100644 wwwroot/i18n/zh/i18n.json create mode 100644 wwwroot/i18n_getmsgs.dspy diff --git a/scripts/load_path.py b/scripts/load_path.py index e5828ac..37978ff 100644 --- a/scripts/load_path.py +++ b/scripts/load_path.py @@ -11,6 +11,7 @@ PATHS_ANY = [ f"/{MOD}/cron/etl_sync.dspy", f"/{MOD}/cron/etl_aggregate.dspy", f"/{MOD}/cron/etl_provider_cost.dspy", + f"/{MOD}/i18n_getmsgs", ] PATHS_LOGINED = [ diff --git a/wwwroot/i18n/en/i18n.json b/wwwroot/i18n/en/i18n.json new file mode 100644 index 0000000..3c1a8ab --- /dev/null +++ b/wwwroot/i18n/en/i18n.json @@ -0,0 +1,12 @@ +{ + "API Key排行": "API Key Ranking", + "供应商性价比": "Provider Cost-Performance", + "供应商性价比对比": "Provider ROI Comparison", + "供应商排行": "Provider Ranking", + "币种分布": "Currency Distribution", + "我的模型(按金额Top5)": "My Models (Top 5 by Amount)", + "模型性能排行": "Model Performance Ranking", + "热门模型": "Popular Models", + "用户排行": "User Ranking", + "财务概览": "Financial Overview" +} diff --git a/wwwroot/i18n/jp/i18n.json b/wwwroot/i18n/jp/i18n.json new file mode 100644 index 0000000..b1d08f0 --- /dev/null +++ b/wwwroot/i18n/jp/i18n.json @@ -0,0 +1,12 @@ +{ + "API Key排行": "APIキーランキング", + "供应商性价比": "プロバイダーコストパフォーマンス", + "供应商性价比对比": "プロバイダーROI比較", + "供应商排行": "プロバイダーランキング", + "币种分布": "通貨分布", + "我的模型(按金额Top5)": "マイモデル(金額Top5)", + "模型性能排行": "モデルパフォーマンスランキング", + "热门模型": "人気モデル", + "用户排行": "ユーザーランキング", + "财务概览": "財務概要" +} diff --git a/wwwroot/i18n/ko/i18n.json b/wwwroot/i18n/ko/i18n.json new file mode 100644 index 0000000..2fe34bc --- /dev/null +++ b/wwwroot/i18n/ko/i18n.json @@ -0,0 +1,12 @@ +{ + "API Key排行": "API 키 랭킹", + "供应商性价比": "공급업체 가성비", + "供应商性价比对比": "공급업체 ROI 비교", + "供应商排行": "공급업체 랭킹", + "币种分布": "통화 분포", + "我的模型(按金额Top5)": "내 모델 (금액 Top5)", + "模型性能排行": "모델 성능 랭킹", + "热门模型": "인기 모델", + "用户排行": "사용자 랭킹", + "财务概览": "재무 개요" +} diff --git a/wwwroot/i18n/zh/i18n.json b/wwwroot/i18n/zh/i18n.json new file mode 100644 index 0000000..dc8a148 --- /dev/null +++ b/wwwroot/i18n/zh/i18n.json @@ -0,0 +1,12 @@ +{ + "API Key排行": "API Key排行", + "供应商性价比": "供应商性价比", + "供应商性价比对比": "供应商性价比对比", + "供应商排行": "供应商排行", + "币种分布": "币种分布", + "我的模型(按金额Top5)": "我的模型(按金额Top5)", + "模型性能排行": "模型性能排行", + "热门模型": "热门模型", + "用户排行": "用户排行", + "财务概览": "财务概览" +} diff --git a/wwwroot/i18n_getmsgs.dspy b/wwwroot/i18n_getmsgs.dspy new file mode 100644 index 0000000..f201052 --- /dev/null +++ b/wwwroot/i18n_getmsgs.dspy @@ -0,0 +1,13 @@ +import json, os + +lang = params.get('lang', 'zh') +i18n_dir = os.path.join(os.path.dirname(__file__), 'i18n', lang) +i18n_file = os.path.join(i18n_dir, 'i18n.json') + +if os.path.exists(i18n_file): + with open(i18n_file, 'r', encoding='utf-8') as f: + msgs = json.load(f) +else: + msgs = {} + +return json.dumps(msgs, ensure_ascii=False)