diff --git a/wwwroot/i18n_getmsgs b/wwwroot/i18n_getmsgs new file mode 100644 index 0000000..46ccf78 --- /dev/null +++ b/wwwroot/i18n_getmsgs @@ -0,0 +1,17 @@ +#!/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)