vue-i18n-extract-plugin 1.0.57 → 1.0.58

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/README.md CHANGED
@@ -24,10 +24,10 @@ yarn global add vue-i18n-extract-plugin
24
24
  ## CLI
25
25
 
26
26
  ```bash
27
- extract-i18n --includePath=demo --rewrite
27
+ extract-i18n --includePath=demo/src --rewrite
28
28
  ```
29
29
 
30
- 这会提取demo目录下的所有`allowedExtensions`文件的`fromLang`,并生成一个对应的JSON文件,如果开启了自动翻译,则会自动翻译并生成对应的翻译JSON文件.
30
+ 这会提取demo/src目录下的所有`allowedExtensions`文件的`fromLang`,并生成一个对应的JSON文件,如果开启了自动翻译,则会自动翻译并生成对应的翻译JSON文件.
31
31
 
32
32
  ## Programming API
33
33
 
package/lib/visitors.js CHANGED
@@ -37,7 +37,7 @@ function isJSXElement(path, nodeName) {
37
37
  ) {
38
38
  const jsxAttr = path.findParent(p => p.isJSXAttribute());
39
39
  const attrName = jsxAttr.node.name.name;
40
- if (attrName === "defaultMsg" || attrName === "values") {
40
+ if (attrName === "msg" || attrName === "values") {
41
41
  return true;
42
42
  }
43
43
  }
@@ -185,7 +185,7 @@ function createI18nVisitor(option, i18nMap) {
185
185
  return;
186
186
  }
187
187
 
188
- // 跳过<Trans defaultMsg="你好,{name}" values={{name: '世界'} /> defaultMsg和values属性的转换
188
+ // 跳过<Trans msg="你好,{name}" values={{name: '世界'} /> msg和values属性的转换
189
189
  if (isJSXElement(path, option.JSXElement)) {
190
190
  return;
191
191
  }
@@ -382,7 +382,7 @@ function createI18nVisitor(option, i18nMap) {
382
382
  }
383
383
  },
384
384
  JSXElement(path) {
385
- // <Trans id="aaa" defaultMsg="xxx" />
385
+ // <Trans id="aaa" msg="xxx" />
386
386
  const openingElement = path.node.openingElement;
387
387
  if (
388
388
  !t.isJSXIdentifier(openingElement.name) ||
@@ -393,9 +393,9 @@ function createI18nVisitor(option, i18nMap) {
393
393
 
394
394
  let idAttr = null;
395
395
  let idValue = null;
396
- let defaultMsgValue = null;
396
+ let msgValue = null;
397
397
 
398
- // 遍历属性,查找 id 和 defaultMsg
398
+ // 遍历属性,查找 id 和 msg
399
399
  openingElement.attributes.forEach(attr => {
400
400
  if (!t.isJSXAttribute(attr) || !t.isJSXIdentifier(attr.name)) return;
401
401
 
@@ -406,26 +406,26 @@ function createI18nVisitor(option, i18nMap) {
406
406
  }
407
407
  }
408
408
 
409
- if (attr.name.name === "defaultMsg") {
409
+ if (attr.name.name === "msg") {
410
410
  if (attr.value && t.isStringLiteral(attr.value)) {
411
- defaultMsgValue = attr.value.value;
411
+ msgValue = attr.value.value;
412
412
  }
413
413
  }
414
414
  });
415
415
 
416
- // 计算 id,如果未提供,则使用 defaultMsg 的哈希值
417
- if (!idValue && defaultMsgValue) {
418
- idValue = generateId(defaultMsgValue, option);
416
+ // 计算 id,如果未提供,则使用 msg 的哈希值
417
+ if (!idValue && msgValue) {
418
+ idValue = generateId(msgValue, option);
419
419
 
420
420
  if (i18nMap) {
421
- i18nMap[idValue] = defaultMsgValue;
421
+ i18nMap[idValue] = msgValue;
422
422
  }
423
423
  }
424
424
 
425
- // 有id并且有defaultMsg的情况
426
- if (idValue && defaultMsgValue) {
425
+ // 有id并且有msg的情况
426
+ if (idValue && msgValue) {
427
427
  if (i18nMap) {
428
- i18nMap[idValue] = defaultMsgValue;
428
+ i18nMap[idValue] = msgValue;
429
429
  }
430
430
  }
431
431
 
@@ -441,13 +441,13 @@ function createI18nVisitor(option, i18nMap) {
441
441
  }
442
442
 
443
443
  if (!option.keepDefaultMsg && !option.keepRaw) {
444
- // 移除 defaultMsg
444
+ // 移除 msg
445
445
  openingElement.attributes = openingElement.attributes.filter(
446
446
  attr =>
447
447
  !(
448
448
  t.isJSXAttribute(attr) &&
449
449
  t.isJSXIdentifier(attr.name) &&
450
- attr.name.name === "defaultMsg"
450
+ attr.name.name === "msg"
451
451
  )
452
452
  );
453
453
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-i18n-extract-plugin",
3
- "version": "1.0.57",
3
+ "version": "1.0.58",
4
4
  "main": "lib/index.js",
5
5
  "types": "types/index.d.ts",
6
6
  "bin": {