pipeline-app/wwwroot/i18n_getmsgs

18 lines
493 B
Python

#!/usr/bin/env python3
"""i18n messages endpoint for bricks framework"""
import json
import os
lang = params_kw.get('lang', 'zh-CN')
i18n_name = params_kw.get('i18n', 'i18n')
msgs = {}
i18n_dir = os.path.join(os.path.dirname(__file__), 'i18n', lang)
i18n_file = os.path.join(i18n_dir, f'{i18n_name}.json')
if os.path.exists(i18n_file):
with open(i18n_file, 'r', encoding='utf-8') as f:
msgs = json.load(f)
return json.dumps({"success": True, "msgs": msgs}, ensure_ascii=False)