vite-gc-i18n-plugin 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2738,12 +2738,22 @@ function translateSetLang(node) {
2738
2738
  let arg = node.arguments || [];
2739
2739
  // 提取参数作为值
2740
2740
  // 检查参数是否为字符串字面量
2741
- const id = types__namespace.isStringLiteral(arg[0]) ? arg[0].value : '';
2742
- const value = types__namespace.isStringLiteral(arg[1]) ? arg[1].value : '';
2741
+ const idArg = arg[0];
2742
+ const valueArg = arg[1];
2743
+ const id = types__namespace.isStringLiteral(idArg) ? idArg.value : '';
2744
+ const value = types__namespace.isStringLiteral(valueArg) ? valueArg.value : '';
2743
2745
  // 检查 ID 和值是否存在,并且第二个参数是字符串字面量
2744
- if (id && value && types__namespace.isStringLiteral(arg[1])) {
2746
+ if (id && value && types__namespace.isStringLiteral(idArg) && types__namespace.isStringLiteral(valueArg)) {
2747
+ const resolvedId = resolveLangKey(id, value);
2748
+ if (resolvedId !== id) {
2749
+ idArg.value = resolvedId;
2750
+ idArg.extra = {
2751
+ raw: `'${resolvedId}'`,
2752
+ rawValue: resolvedId
2753
+ };
2754
+ }
2745
2755
  // 调用翻译工具的 setLangObj 方法设置语言对象属性
2746
- setLangObj(id, value);
2756
+ setLangObj(resolvedId, value);
2747
2757
  }
2748
2758
  }
2749
2759