原代码: os.path.dirname(__file__) + lang → wwwroot/{lang}/i18n.json (不存在)
修正为: + 'i18n' + lang → wwwroot/i18n/{lang}/i18n.json (正确)
同时重跑 merge_i18n.py 确保生成最新合并文件
15 lines
346 B
Plaintext
15 lines
346 B
Plaintext
import json
|
|
import 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)
|