Browse Source

feat(i18n): enable pluralization for count-based translations

Enable i18next pluralization by setting disablePlurals to false and update multiple translation keys to use _one/_other suffixes for proper singular/plural handling. This improves localization accuracy for count-dependent strings like "X keys", "X models", and "X times".
Dmitriy Safonov 3 months ago
parent
commit
5810c05dab
3 changed files with 29 additions and 20 deletions
  1. 2 2
      web/i18next.config.js
  2. 18 9
      web/src/i18n/locales/en.json
  3. 9 9
      web/src/i18n/locales/zh.json

+ 2 - 2
web/i18next.config.js

@@ -82,10 +82,10 @@ export default defineConfig({
       "validateStatus",
       "value",
       "viewBox",
-      "width",
+      "width"
     ],
     sort: true,
-    disablePlurals: true,
+    disablePlurals: false,
     removeUnusedKeys: true,
     nsSeparator: false,
     keySeparator: false,

+ 18 - 9
web/src/i18n/locales/en.json

@@ -1,8 +1,10 @@
 {
   "translation": {
-    " + Web搜索 {{count}}次 / 1K 次 * {{symbol}}{{price}} * {{ratioType}} {{ratio}}": " + Web search {{count}} times / 1K times * {{symbol}}{{price}} * {{ratioType}} {{ratio}}",
+    " + Web搜索 {{count}}次 / 1K 次 * {{symbol}}{{price}} * {{ratioType}} {{ratio}}_one": " + Web search {{count}} time / 1K times * {{symbol}}{{price}} * {{ratioType}} {{ratio}}",
+    " + Web搜索 {{count}}次 / 1K 次 * {{symbol}}{{price}} * {{ratioType}} {{ratio}}_other": " + Web search {{count}} times / 1K times * {{symbol}}{{price}} * {{ratioType}} {{ratio}}",
     " + 图片生成调用 {{symbol}}{{price}} / 1次 * {{ratioType}} {{ratio}}": " + Image generation call {{symbol}}{{price}} / 1 time * {{ratioType}} {{ratio}}",
-    " + 文件搜索 {{count}}次 / 1K 次 * {{symbol}}{{price}} * {{ratioType}} {{ratio}}": " + File search {{count}} times / 1K times * {{symbol}}{{price}} * {{ratioType}} {{ratio}}",
+    " + 文件搜索 {{count}}次 / 1K 次 * {{symbol}}{{price}} * {{ratioType}} {{ratio}}_one": " + File search {{count}} time / 1K times * {{symbol}}{{price}} * {{ratioType}} {{ratio}}",
+    " + 文件搜索 {{count}}次 / 1K 次 * {{symbol}}{{price}} * {{ratioType}} {{ratio}}_other": " + File search {{count}} times / 1K times * {{symbol}}{{price}} * {{ratioType}} {{ratio}}",
     " 个模型设置相同的值": " models with the same value",
     " 吗?": "?",
     " 秒": "s",
@@ -398,7 +400,8 @@
     "公告更新失败": "Notice update failed",
     "公告类型": "Notice Type",
     "共": "Total",
-    "共 {{count}} 个密钥": "Total {{count}} keys",
+    "共 {{count}} 个密钥_one": "{{count}} key",
+    "共 {{count}} 个密钥_other": "{{count}} keys",
     "共 {{count}} 个模型": "{{count}} models",
     "共 {{total}} 项,当前显示 {{start}}-{{end}} 项": "{{total}} items total, showing {{start}}-{{end}} items",
     "关": "close",
@@ -707,7 +710,8 @@
     "展开": "Expand",
     "展开更多": "Expand more",
     "左侧边栏个人设置": "Personal settings in left sidebar",
-    "已为 {{count}} 个模型设置{{type}}": "Set {{type}} for {{count}} models",
+    "已为 {{count}} 个模型设置{{type}}_one": "Set {{type}} for {{count}} model",
+    "已为 {{count}} 个模型设置{{type}}_other": "Set {{type}} for {{count}} models",
     "已为 ${count} 个渠道设置标签!": "Set tags for ${count} channels!",
     "已修复 ${success} 个通道,失败 ${fails} 个通道。": "Fixed ${success} channels, failed ${fails} channels.",
     "已停止批量测试": "Stopped batch testing",
@@ -717,7 +721,8 @@
     "已切换至最优倍率视图,每个模型使用其最低倍率分组": "Switched to the optimal ratio view, each model uses its lowest ratio group",
     "已初始化": "Initialized",
     "已删除 {{count}} 个令牌!": "Deleted {{count}} tokens!",
-    "已删除 {{count}} 条失效兑换码": "Deleted {{count}} expired redemption codes",
+    "已删除 {{count}} 条失效兑换码_one": "Deleted {{count}} expired redemption code",
+    "已删除 {{count}} 条失效兑换码_other": "Deleted {{count}} expired redemption codes",
     "已删除 ${data} 个通道!": "Deleted ${data} channels!",
     "已删除所有禁用渠道,共计 ${data} 个": "Deleted all disabled channels, total ${data}",
     "已删除消息及其回复": "Deleted message and its replies",
@@ -737,7 +742,8 @@
     "已复制模型名称": "Model name copied",
     "已成功开始测试所有已启用通道,请刷新页面查看结果。": "Successfully started testing all enabled channels. Please refresh page to view results.",
     "已提交": "Submitted",
-    "已新增 {{count}} 个模型:{{list}}": "Added {{count}} models: {{list}}",
+    "已新增 {{count}} 个模型:{{list}}_one": "Added {{count}} model: {{list}}",
+    "已新增 {{count}} 个模型:{{list}}_other": "Added {{count}} models: {{list}}",
     "已更新完毕所有已启用通道余额!": "Updated quota for all enabled channels!",
     "已有保存的配置": "There are saved configurations",
     "已有的模型": "Existing models",
@@ -753,7 +759,8 @@
     "已绑定渠道": "Bound channels",
     "已耗尽": "Exhausted",
     "已过期": "Expired",
-    "已选择 {{count}} 个模型": "Selected {{count}} models",
+    "已选择 {{count}} 个模型_one": "Selected {{count}} model",
+    "已选择 {{count}} 个模型_other": "Selected {{count}} models",
     "已选择 {{selected}} / {{total}}": "Selected {{selected}} / {{total}}",
     "已选择 ${count} 个渠道": "Selected ${count} channels",
     "已重置为默认配置": "Reset to default configuration",
@@ -1361,8 +1368,10 @@
     "确定要修改所有子渠道权重为 ": "Confirm to modify all sub-channel weights to ",
     "确定要删除供应商 \"{{name}}\" 吗?此操作不可撤销。": "Are you sure you want to delete supplier \"{{name}}\"? This operation is irreversible.",
     "确定要删除所有已自动禁用的密钥吗?": "Are you sure you want to delete all automatically disabled keys?",
-    "确定要删除所选的 {{count}} 个令牌吗?": "Are you sure you want to delete the selected {{count}} tokens?",
-    "确定要删除所选的 {{count}} 个模型吗?": "Are you sure you want to delete the selected {{count}} models?",
+    "确定要删除所选的 {{count}} 个令牌吗?_one": "Are you sure you want to delete the selected {{count}} token?",
+    "确定要删除所选的 {{count}} 个令牌吗?_other": "Are you sure you want to delete the selected {{count}} tokens?",
+    "确定要删除所选的 {{count}} 个模型吗?_one": "Are you sure you want to delete the selected {{count}} model?",
+    "确定要删除所选的 {{count}} 个模型吗?_other": "Are you sure you want to delete the selected {{count}} models?",
     "确定要删除此API信息吗?": "Are you sure you want to delete this API information?",
     "确定要删除此公告吗?": "Are you sure you want to delete this notice?",
     "确定要删除此分类吗?": "Are you sure you want to delete this category?",

+ 9 - 9
web/src/i18n/locales/zh.json

@@ -1,8 +1,8 @@
 {
   "translation": {
-    " + Web搜索 {{count}}次 / 1K 次 * {{symbol}}{{price}} * {{ratioType}} {{ratio}}": " + Web搜索 {{count}}次 / 1K 次 * {{symbol}}{{price}} * {{ratioType}} {{ratio}}",
+    " + Web搜索 {{count}}次 / 1K 次 * {{symbol}}{{price}} * {{ratioType}} {{ratio}}_other": " + Web搜索 {{count}}次 / 1K 次 * {{symbol}}{{price}} * {{ratioType}} {{ratio}}",
     " + 图片生成调用 {{symbol}}{{price}} / 1次 * {{ratioType}} {{ratio}}": " + 图片生成调用 {{symbol}}{{price}} / 1次 * {{ratioType}} {{ratio}}",
-    " + 文件搜索 {{count}}次 / 1K 次 * {{symbol}}{{price}} * {{ratioType}} {{ratio}}": " + 文件搜索 {{count}}次 / 1K 次 * {{symbol}}{{price}} * {{ratioType}} {{ratio}}",
+    " + 文件搜索 {{count}}次 / 1K 次 * {{symbol}}{{price}} * {{ratioType}} {{ratio}}_other": " + 文件搜索 {{count}}次 / 1K 次 * {{symbol}}{{price}} * {{ratioType}} {{ratio}}",
     " 个模型设置相同的值": " 个模型设置相同的值",
     " 吗?": " 吗?",
     " 秒": " 秒",
@@ -398,7 +398,7 @@
     "公告更新失败": "公告更新失败",
     "公告类型": "公告类型",
     "共": "共",
-    "共 {{count}} 个密钥": "共 {{count}} 个密钥",
+    "共 {{count}} 个密钥_other": "共 {{count}} 个密钥",
     "共 {{count}} 个模型": "共 {{count}} 个模型",
     "共 {{total}} 项,当前显示 {{start}}-{{end}} 项": "共 {{total}} 项,当前显示 {{start}}-{{end}} 项",
     "关": "关",
@@ -707,7 +707,7 @@
     "展开": "展开",
     "展开更多": "展开更多",
     "左侧边栏个人设置": "左侧边栏个人设置",
-    "已为 {{count}} 个模型设置{{type}}": "已为 {{count}} 个模型设置{{type}}",
+    "已为 {{count}} 个模型设置{{type}}_other": "已为 {{count}} 个模型设置{{type}}",
     "已为 ${count} 个渠道设置标签!": "已为 ${count} 个渠道设置标签!",
     "已修复 ${success} 个通道,失败 ${fails} 个通道。": "已修复 ${success} 个通道,失败 ${fails} 个通道。",
     "已停止批量测试": "已停止批量测试",
@@ -717,7 +717,7 @@
     "已切换至最优倍率视图,每个模型使用其最低倍率分组": "已切换至最优倍率视图,每个模型使用其最低倍率分组",
     "已初始化": "已初始化",
     "已删除 {{count}} 个令牌!": "已删除 {{count}} 个令牌!",
-    "已删除 {{count}} 条失效兑换码": "已删除 {{count}} 条失效兑换码",
+    "已删除 {{count}} 条失效兑换码_other": "已删除 {{count}} 条失效兑换码",
     "已删除 ${data} 个通道!": "已删除 ${data} 个通道!",
     "已删除所有禁用渠道,共计 ${data} 个": "已删除所有禁用渠道,共计 ${data} 个",
     "已删除消息及其回复": "已删除消息及其回复",
@@ -737,7 +737,7 @@
     "已复制模型名称": "已复制模型名称",
     "已成功开始测试所有已启用通道,请刷新页面查看结果。": "已成功开始测试所有已启用通道,请刷新页面查看结果。",
     "已提交": "已提交",
-    "已新增 {{count}} 个模型:{{list}}": "已新增 {{count}} 个模型:{{list}}",
+    "已新增 {{count}} 个模型:{{list}}_other": "已新增 {{count}} 个模型:{{list}}",
     "已更新完毕所有已启用通道余额!": "已更新完毕所有已启用通道余额!",
     "已有保存的配置": "已有保存的配置",
     "已有的模型": "已有的模型",
@@ -753,7 +753,7 @@
     "已绑定渠道": "已绑定渠道",
     "已耗尽": "已耗尽",
     "已过期": "已过期",
-    "已选择 {{count}} 个模型": "已选择 {{count}} 个模型",
+    "已选择 {{count}} 个模型_other": "已选择 {{count}} 个模型",
     "已选择 {{selected}} / {{total}}": "已选择 {{selected}} / {{total}}",
     "已选择 ${count} 个渠道": "已选择 ${count} 个渠道",
     "已重置为默认配置": "已重置为默认配置",
@@ -1361,8 +1361,8 @@
     "确定要修改所有子渠道权重为 ": "确定要修改所有子渠道权重为 ",
     "确定要删除供应商 \"{{name}}\" 吗?此操作不可撤销。": "确定要删除供应商 \"{{name}}\" 吗?此操作不可撤销。",
     "确定要删除所有已自动禁用的密钥吗?": "确定要删除所有已自动禁用的密钥吗?",
-    "确定要删除所选的 {{count}} 个令牌吗?": "确定要删除所选的 {{count}} 个令牌吗?",
-    "确定要删除所选的 {{count}} 个模型吗?": "确定要删除所选的 {{count}} 个模型吗?",
+    "确定要删除所选的 {{count}} 个令牌吗?_other": "确定要删除所选的 {{count}} 个令牌吗?",
+    "确定要删除所选的 {{count}} 个模型吗?_other": "确定要删除所选的 {{count}} 个模型吗?",
     "确定要删除此API信息吗?": "确定要删除此API信息吗?",
     "确定要删除此公告吗?": "确定要删除此公告吗?",
     "确定要删除此分类吗?": "确定要删除此分类吗?",