@talend/i18n-scripts
Advanced tools
Comparing version 0.6.1 to 0.7.0
@@ -23,3 +23,3 @@ # Deploy | ||
"github": { | ||
"url": "https://github.com/Talend/locales.git" | ||
"url": "https://github.com/Talend/i18n-product.git" | ||
}, | ||
@@ -26,0 +26,0 @@ "module": { |
@@ -40,3 +40,4 @@ # Upload/Download | ||
"load": { | ||
"project": "UI" | ||
"project": "UI", | ||
"fixQuote": true | ||
} | ||
@@ -49,3 +50,4 @@ } | ||
| project | The XTM project name. | | ||
| fixQuote | transforms odd numbers of quote on properties files | | ||
It will download only the files corresponding to the current version of your project (version extracted). If no version is detected, all versions will be downloaded. |
{ | ||
"name": "@talend/i18n-scripts", | ||
"description": "Set of scripts to ease i18n workflow", | ||
"version": "0.6.1", | ||
"version": "0.7.0", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
@@ -11,2 +11,38 @@ const fs = require('fs'); | ||
// find odd number of following quote and capture them | ||
const REGEX_SINGLE_QUOTE = /([^']|^)'('')*(?!')/g; | ||
function replaceOddQuote(fileName) { | ||
const content = fs.readFileSync(fileName, 'utf-8'); | ||
const newValue = content.replace(REGEX_SINGLE_QUOTE, '$&\''); | ||
fs.writeFileSync(fileName, newValue); | ||
} | ||
function findPropertiesFiles(currentPath) { | ||
const propsFiles = []; | ||
if (!fs.existsSync(currentPath)){ | ||
return propsFiles; | ||
} | ||
fs.readdirSync(currentPath).forEach(file => { | ||
const filename = path.join(currentPath,file); | ||
if ( fs.lstatSync(filename).isDirectory()){ | ||
propsFiles.push(...findPropertiesFiles(filename)); | ||
} else if (filename.endsWith('.properties')) { | ||
propsFiles.push(filename); | ||
} | ||
}); | ||
return propsFiles; | ||
} | ||
function fixOddQuote(data) { | ||
const { targetPath, fixQuote} = data; | ||
if (fixQuote) { | ||
fs.readdirSync(targetPath) | ||
.map(currentFolder => path.join(targetPath, currentFolder)) | ||
.flatMap(findPropertiesFiles) | ||
.forEach(replaceOddQuote); | ||
} | ||
return data; | ||
} | ||
function unzip(data) { | ||
@@ -66,2 +102,3 @@ const { targetPath } = data; | ||
version: getVersion(), | ||
fixQuote: load.fixQuote | ||
}; | ||
@@ -74,2 +111,3 @@ printSection('XTM'); | ||
.then(unzip) | ||
.then(fixOddQuote) | ||
.then(reshapeFolders) | ||
@@ -76,0 +114,0 @@ .catch(e => { |
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
144630
1434