From 5882c5c150517e8cf5b865cb43f015d4f4f84f21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Mon, 25 Mar 2024 22:48:16 +0800 Subject: [PATCH] update locale --- modules/dice/locales/en_us.json | 8 ++++---- modules/dice/locales/zh_cn.json | 8 ++++---- modules/dice/locales/zh_tw.json | 8 ++++---- modules/dice/process.py | 6 ++++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/modules/dice/locales/en_us.json b/modules/dice/locales/en_us.json index 7dff252365..b9e424dc09 100644 --- a/modules/dice/locales/en_us.json +++ b/modules/dice/locales/en_us.json @@ -8,8 +8,6 @@ "dice.message.dc.failed": "Failed!", "dice.message.dc.invalid": "Invalid DC: ", "dice.message.dc.success": "Success!", - "dice.message.set.success": "Successfully set the default sides to ${face}.", - "dice.message.set.clear": "Successfully cleared the default sides.", "dice.message.error": "Unable to parse the dice expression: ", "dice.message.error.invalid": "Unrecognized characters in dice expression.", "dice.message.error.prompt": "Item ${i} occurs: ", @@ -18,18 +16,20 @@ "dice.message.error.value.k.invalid": "Invalid advantages and disadvantages.", "dice.message.error.value.k.out_of_range": "The number of advantage and disadvantage dice is greater than the total number of dice.", "dice.message.error.value.m.invalid": "Invalid number of dice.", + "dice.message.error.value.m.out_of_range": "The number of dice cannot be less than 1 or greater than ${max}.", "dice.message.error.value.n.d1": "D1?", "dice.message.error.value.n.invalid": "Invalid sides number of dice.", "dice.message.error.value.n.less_2": "The sides number of dice cannot be less than 2.", "dice.message.error.value.N.out_of_range": "The number of dice roll cannot be less than 1 or greater than ${max}.", - "dice.message.error.value.m.out_of_range": "The number of dice cannot be less than 1 or greater than ${max}.", "dice.message.error.value.too_long": "The number of items in the dice expression exceeds the limit.", "dice.message.error.value.y.invalid": "Invalid adjustment value.", "dice.message.error.value.y.out_of_range": "The adjustment value cannot be less than ${min} or greater than ${max}.", - "dice.message.N.invalid": "Invalid number of dice rolls: ", + "dice.message.N.invalid": "Invalid number of dice rolls.", "dice.message.output": "Your result: ", "dice.message.output.too_long": "${length} items have been omitted", "dice.message.rule.disable": "The check rule has been changed to forward.", "dice.message.rule.enable": "The check rule has been changed to reverse.", + "dice.message.set.clear": "Successfully cleared the default sides.", + "dice.message.set.success": "Successfully set the default sides to ${face}.", "dice.message.too_long": "Output is too long..." } \ No newline at end of file diff --git a/modules/dice/locales/zh_cn.json b/modules/dice/locales/zh_cn.json index 8cc0eb7c59..c2c0e5229b 100644 --- a/modules/dice/locales/zh_cn.json +++ b/modules/dice/locales/zh_cn.json @@ -8,8 +8,6 @@ "dice.message.dc.failed": "判定失败!", "dice.message.dc.invalid": "无效的 DC:", "dice.message.dc.success": "判定成功!", - "dice.message.set.success": "成功设置骰子默认面数为 ${face}。", - "dice.message.set.clear": "成功清除骰子默认面数。", "dice.message.error": "无法解析骰子表达式:", "dice.message.error.invalid": "骰子表达式中存在无法识别的字符。", "dice.message.error.prompt": "第 ${i} 项发生:", @@ -18,18 +16,20 @@ "dice.message.error.value.k.invalid": "无效的优劣势。", "dice.message.error.value.k.out_of_range": "优劣势骰数大于总骰子数。", "dice.message.error.value.m.invalid": "无效的骰子数量。", + "dice.message.error.value.m.out_of_range": "骰子数量不得小于 1 或大于 ${max}。", "dice.message.error.value.n.d1": "1 面的骰子?", "dice.message.error.value.n.invalid": "无效的骰子面数。", "dice.message.error.value.n.less_2": "骰子面数不得小于 2。", "dice.message.error.value.N.out_of_range": "投骰次数不得小于 1 或大于 ${max}。", - "dice.message.error.value.m.out_of_range": "骰子数量不得小于 1 或大于 ${max}。", "dice.message.error.value.too_long": "骰子表达式项数超过限制。", "dice.message.error.value.y.invalid": "无效的调节值项。", "dice.message.error.value.y.out_of_range": "调节值不得小于 ${min} 或大于 ${max}。", - "dice.message.N.invalid": "无效的投骰次数:", + "dice.message.N.invalid": "无效的投骰次数。", "dice.message.output": "你掷得的结果是:", "dice.message.output.too_long": "数量过大,已省略 ${length} 条数据", "dice.message.rule.disable": "判定规则已更改为正向。", "dice.message.rule.enable": "判定规则已更改为反向。", + "dice.message.set.clear": "成功清除骰子默认面数。", + "dice.message.set.success": "成功设置骰子默认面数为 ${face}。", "dice.message.too_long": "输出过长……" } \ No newline at end of file diff --git a/modules/dice/locales/zh_tw.json b/modules/dice/locales/zh_tw.json index 35e11d1752..e162894efd 100644 --- a/modules/dice/locales/zh_tw.json +++ b/modules/dice/locales/zh_tw.json @@ -8,8 +8,6 @@ "dice.message.dc.failed": "判定失敗!", "dice.message.dc.invalid": "無效的 DC:", "dice.message.dc.success": "判定成功!", - "dice.message.set.success": "成功設定預設骰子面數為 ${face}。", - "dice.message.set.clear": "成功清除預設骰子面數。", "dice.message.error": "無法解析骰子運算式:", "dice.message.error.invalid": "骰子語句中存在無法辨識的字元。", "dice.message.error.prompt": "第 ${i} 項發生:", @@ -18,18 +16,20 @@ "dice.message.error.value.k.invalid": "無效的優劣勢。", "dice.message.error.value.k.out_of_range": "優劣势骰數大於總骰子數。", "dice.message.error.value.m.invalid": "無效的骰子數量。", + "dice.message.error.value.m.out_of_range": "骰子數量不得小於 1 或大於 ${max}。", "dice.message.error.value.n.d1": "1 面的骰子?", "dice.message.error.value.n.invalid": "無效的骰子面數。", "dice.message.error.value.n.less_2": "骰子面數不得小於 2。", - "dice.message.error.value.m.out_of_range": "骰子數量不得小於 1 或大於 ${max}。", "dice.message.error.value.N.out_of_range": "投骰次數不得小於 1 或大於 ${max}。", "dice.message.error.value.too_long": "骰子運算式項數超過限制。", "dice.message.error.value.y.invalid": "無效的調整值項。", "dice.message.error.value.y.out_of_range": "調整值不得小於 ${min} 或大於 ${max}。", - "dice.message.N.invalid": "無效的投骰次數:", + "dice.message.N.invalid": "無效的投骰次數。", "dice.message.output": "你掷得的結果是:", "dice.message.output.too_long": "數量過大,已省略 ${length} 條資訊", "dice.message.rule.disable": "判定規則已更改為正向。", "dice.message.rule.enable": "判定規則已更改為反向。", + "dice.message.set.clear": "成功清除預設骰子面數。", + "dice.message.set.success": "成功設定預設骰子面數為 ${face}。", "dice.message.too_long": "輸出過長……" } \ No newline at end of file diff --git a/modules/dice/process.py b/modules/dice/process.py index df8a16f28b..45c3879c66 100644 --- a/modules/dice/process.py +++ b/modules/dice/process.py @@ -74,7 +74,8 @@ def parse_dice_expression(msg, dices): else: times = '1' if not times.isdigit(): - return None, None, None, DiceValueError(msg, msg.locale.t('dice.message.N.invalid'), times).message + errmsg = msg.locale.t('dice.message.N.invalid') + return None, None, None, DiceValueError(msg, msg.locale.t('dice.message.error') + '\n' + errmsg).message dice_expr_list = re.split(f'{math_func_pattern}|' + '|'.join(patterns), dices, flags=re.I) dice_expr_list = [item for item in dice_expr_list if item] # 清除空白元素 @@ -96,7 +97,8 @@ def parse_dice_expression(msg, dices): Logger.debug(dice_expr_list) if len(dice_item_list) > MAX_ITEM_COUNT: - return None, None, None, DiceValueError(msg, msg.locale.t('dice.message.error.value.too_long')).message + errmsg = msg.locale.t('dice.message.error.value.too_long') + return None, None, None, DiceValueError(msg, msg.locale.t('dice.message.error') + '\n' + errmsg).message dice_count = 0 # 初始化骰子序列