linkmore-intl-generator
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -35,2 +35,6 @@ "use strict"; | ||
} | ||
// 去除引号 | ||
stripQuotation(s) { | ||
return s.replace(/^('|")/, '').replace(/'|"$/, ''); | ||
} | ||
translationLanguage(sourceLanguage = 'zh', targetLanguage = 'en', dataSource = []) { | ||
@@ -79,5 +83,5 @@ return __awaiter(this, void 0, void 0, function* () { | ||
const toHump = (name) => { | ||
return name | ||
.replace(/[^a-zA-Z0-9 ]/g, '') | ||
.replace(/( *)(\w)/g, (all) => all.trim().toUpperCase()); | ||
return name.replace(/[^a-zA-Z0-9 ]/g, '').replace(/( +)(\w)/g, (all) => { | ||
return all.trim().toUpperCase(); | ||
}); | ||
}; | ||
@@ -130,3 +134,3 @@ const result = {}; | ||
if (this.haveChineseReg.test(text)) { | ||
result.push(text.trim()); | ||
result.push(this.stripQuotation(text.trim())); | ||
} | ||
@@ -137,3 +141,3 @@ }); | ||
if (this.haveChineseReg.test(text)) { | ||
result.push(text.trim()); | ||
result.push(this.stripQuotation(text.trim())); | ||
} | ||
@@ -216,3 +220,3 @@ }); | ||
file.getDescendantsOfKind(ts_morph_1.SyntaxKind.JsxText).forEach((jsx) => { | ||
const text = jsx.getText(false).trim(); | ||
const text = this.stripQuotation(jsx.getText(false).trim()); | ||
if (this.haveChineseReg.test(text)) { | ||
@@ -227,3 +231,3 @@ const targetText = replacer(text); | ||
.forEach((literal) => { | ||
const text = literal.getText(false).trim(); | ||
const text = this.stripQuotation(literal.getText(false).trim()); | ||
if (this.haveChineseReg.test(text)) { | ||
@@ -239,3 +243,3 @@ const targetText = replacer(text); | ||
Variable.getDescendantsOfKind(ts_morph_1.SyntaxKind.StringLiteral).forEach((literal) => { | ||
const text = literal.getText(false).trim(); | ||
const text = this.stripQuotation(literal.getText(false).trim()); | ||
if (this.haveChineseReg.test(text)) { | ||
@@ -242,0 +246,0 @@ const targetText = replacer(text); |
{ | ||
"name": "linkmore-intl-generator", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -55,2 +55,7 @@ import fs from 'fs'; | ||
// 去除引号 | ||
private stripQuotation(s: string) { | ||
return s.replace(/^('|")/, '').replace(/'|"$/, ''); | ||
} | ||
private async translationLanguage( | ||
@@ -106,5 +111,5 @@ sourceLanguage = 'zh', | ||
const toHump = (name: string) => { | ||
return name | ||
.replace(/[^a-zA-Z0-9 ]/g, '') | ||
.replace(/( *)(\w)/g, (all) => all.trim().toUpperCase()); | ||
return name.replace(/[^a-zA-Z0-9 ]/g, '').replace(/( +)(\w)/g, (all) => { | ||
return all.trim().toUpperCase(); | ||
}); | ||
}; | ||
@@ -166,3 +171,3 @@ | ||
if (this.haveChineseReg.test(text)) { | ||
result.push(text.trim()); | ||
result.push(this.stripQuotation(text.trim())); | ||
} | ||
@@ -173,3 +178,3 @@ }); | ||
if (this.haveChineseReg.test(text)) { | ||
result.push(text.trim()); | ||
result.push(this.stripQuotation(text.trim())); | ||
} | ||
@@ -255,3 +260,3 @@ }); | ||
file.getDescendantsOfKind(SyntaxKind.JsxText).forEach((jsx) => { | ||
const text = jsx.getText(false).trim(); | ||
const text = this.stripQuotation(jsx.getText(false).trim()); | ||
if (this.haveChineseReg.test(text)) { | ||
@@ -267,3 +272,3 @@ const targetText = replacer(text); | ||
.forEach((literal) => { | ||
const text = literal.getText(false).trim(); | ||
const text = this.stripQuotation(literal.getText(false).trim()); | ||
if (this.haveChineseReg.test(text)) { | ||
@@ -281,3 +286,3 @@ const targetText = replacer(text); | ||
(literal) => { | ||
const text = literal.getText(false).trim(); | ||
const text = this.stripQuotation(literal.getText(false).trim()); | ||
if (this.haveChineseReg.test(text)) { | ||
@@ -284,0 +289,0 @@ const targetText = replacer(text); |
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
46848
1028