Comparing version 0.1.0 to 0.2.0
@@ -16,2 +16,6 @@ "use strict"; | ||
return true; | ||
}, | ||
"--ignore": function (args, index, options) { | ||
options.ignore = (options.ignore || []).concat([args[index + 1]]); | ||
return true; | ||
} | ||
@@ -69,1 +73,5 @@ }; | ||
}; | ||
exports.ignore = function () { | ||
return exports._.parseArguments(process.argv).ignore || []; | ||
}; |
@@ -16,6 +16,11 @@ "use strict"; | ||
return Promise.all([ | ||
sourceProcessing.readTokensFromSourceCode(parseArguments.patterns(), fileNames), | ||
sourceProcessing.readTokensFromSourceCode( | ||
parseArguments.patterns(), | ||
fileNames, | ||
parseArguments.ignore() | ||
), | ||
sourceProcessing.readTokensFromI18n( | ||
parseArguments.destinationPattern(), | ||
parseArguments.destinationFile() | ||
parseArguments.destinationFile(), | ||
parseArguments.ignore() | ||
) | ||
@@ -48,3 +53,3 @@ ]); | ||
.catch((err) => { | ||
console.log(colors.red(err.message)); | ||
console.log(colors.red(err.toString()), "\n", err.stack); | ||
}); | ||
@@ -71,3 +76,5 @@ }; | ||
}) | ||
.then(console.log); | ||
.catch((err) => { | ||
console.log(colors.red(err.toString()), "\n", err.stack); | ||
}); | ||
}; |
@@ -9,11 +9,17 @@ "use strict"; | ||
exports._.processsSourceCodeFile = function (patterns, fileName) { | ||
exports._.processsSourceCodeFile = function (patterns, fileName, ignoreList) { | ||
return Array.isArray(patterns) && typeof fileName === "string" | ||
? fs.readFile(fileName).then((buffer) => { | ||
let matches; | ||
let content = buffer.toString(); | ||
let content; | ||
let i18nTokens = []; | ||
patterns.forEach(function (pattern) { | ||
content = buffer.toString(); | ||
for (matches = content.match(pattern); matches; matches = content.match(pattern)) { | ||
i18nTokens.push(matches[1].toString()); | ||
if (fileName === "webapp/pages/segment/section/ReceiverWeightingFactor.fragment.xml") { | ||
console.log(matches); | ||
} | ||
if (ignoreList.indexOf(matches[1].toString()) < 0) { | ||
i18nTokens.push(matches[1].toString()); | ||
} | ||
content = content.substring(matches.index + matches[0].length); | ||
@@ -33,7 +39,7 @@ } | ||
exports.readTokensFromSourceCode = function (patternsByFileExt, fileNames) { | ||
exports.readTokensFromSourceCode = function (patternsByFileExt, fileNames, ignoreList) { | ||
return Promise.all( | ||
fileNames.map((fileName) => { | ||
let patterns = patternsByFileExt[path.extname(fileName).replace(/^\./, "")]; | ||
return exports._.processsSourceCodeFile(patterns, fileName); | ||
return exports._.processsSourceCodeFile(patterns, fileName, ignoreList); | ||
}) | ||
@@ -43,3 +49,3 @@ ).then(exports._.unifyTokens); | ||
exports.readTokensFromI18n = function (destinationPattern, fileName) { | ||
exports.readTokensFromI18n = function (destinationPattern, fileName, ignoreList) { | ||
return fs.readFile(fileName).then((buffer) => { | ||
@@ -56,3 +62,3 @@ return buffer | ||
if (match !== null) { | ||
if (match[4] === "#") { | ||
if (match[4] === "#" || ignoreList.indexOf(match[2]) > -1) { | ||
retval.type = CONST.TOKEN.IGNORE; | ||
@@ -59,0 +65,0 @@ } else if (match[1] === "#") { |
{ | ||
"name": "i18n-ui5", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Simplify work with translations in OpenUI5 or SAPUI5 framework. The plugin searches views and source code of project in OpenUI5 or SAPUI5 framework for translation tokens and automatically update translation file used by the framework.", | ||
@@ -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
25035
402