fis3-parser-react-i18n
Advanced tools
Comparing version 0.0.5 to 0.0.6
34
index.js
@@ -28,14 +28,24 @@ var parse = require('@babel/parser').parse; | ||
var chinesePath = languages.find(function (language) { return language.name === 'zh-CN'; }).path; | ||
var code = fs.readFileSync(p.resolve(process.cwd(), chinesePath, 'zh-CN.ts'), 'utf8'); | ||
var ast = parse(code, { | ||
sourceType: 'module', | ||
plugins: ['typescript'] | ||
}); | ||
traverse(ast, { | ||
ObjectProperty: function (path) { | ||
var key = path.node.key.value || path.node.key.name; | ||
var value = path.node.value.value || path.node.value.name; | ||
baseLocale[key] = value; | ||
} | ||
}); | ||
var chineseFunc = function (chinesePath) { | ||
var code = fs.readFileSync(p.resolve(process.cwd(), chinesePath, 'zh-CN.ts'), 'utf8'); | ||
var ast = parse(code, { | ||
sourceType: 'module', | ||
plugins: ['typescript'] | ||
}); | ||
traverse(ast, { | ||
ObjectProperty: function (path) { | ||
var key = path.node.key.value || path.node.key.name; | ||
var value = path.node.value.value || path.node.value.name; | ||
baseLocale[key] = value; | ||
} | ||
}); | ||
}; | ||
if (typeof chinesePath === 'string') { | ||
chineseFunc(chinesePath); | ||
} | ||
else if (Array.isArray(chinesePath)) { | ||
chinesePath.forEach(function (p) { | ||
chineseFunc(p); | ||
}); | ||
} | ||
} | ||
@@ -42,0 +52,0 @@ module.exports = function (content, file, options) { |
{ | ||
"name": "fis3-parser-react-i18n", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "fis3处理react国际化插件", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9470
231