update-translation-keys
Advanced tools
Comparing version 1.0.0 to 1.0.1
23
index.js
@@ -23,4 +23,4 @@ #!/usr/bin/env node | ||
You can also pass a flag 'yaml' if the files are in this format: | ||
update-translation-keys --yaml translations/en.yml translations/fr.json | ||
You can also pass a flag 'yaml=true' if the files are in this format: | ||
update-translation-keys --yaml=true translations/en.yml translations/fr.json | ||
`); | ||
@@ -30,9 +30,20 @@ return; | ||
const [_, ...otherFilesPaths] = filePaths; | ||
const [baseFile, ...otherFiles] = filePaths | ||
.map(path => fs.readFileSync(path, 'utf8')) | ||
.map(parseObject); | ||
.map(path => { | ||
const [_, locale] = /(\w+)\.\w+$/.exec(path); | ||
const file = fs.readFileSync(path, 'utf8'); | ||
const parsedFile = parseObject(file); | ||
return { | ||
locale, | ||
data: parsedFile[locale], | ||
}; | ||
}); | ||
const updatedFiles = otherFiles | ||
.map(otherFile => deepMerge(baseFile, otherFile)); | ||
.map(({ locale, data }) => ({ | ||
[locale]: deepMerge(baseFile.data, object), | ||
})); | ||
filePaths.slice(1) | ||
otherFilesPaths | ||
.forEach((path, i) => { | ||
@@ -39,0 +50,0 @@ const fileToWrite = stringifyObject(updatedFiles[i]); |
{ | ||
"name": "update-translation-keys", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
3124
4
45
1
9