locize-cli
Advanced tools
Comparing version 3.4.3 to 3.5.0
@@ -0,1 +1,4 @@ | ||
## 3.5.0 | ||
- download resources as gettext po format | ||
## 3.4.3 | ||
@@ -2,0 +5,0 @@ - add defaults for download (when calling programmatically) |
@@ -12,2 +12,3 @@ const colors = require('colors'); | ||
const csvjson = require('csvjson'); | ||
const i18nextToPo = require('i18next-conv').i18nextToPo; | ||
@@ -154,2 +155,34 @@ const download = (opt, cb) => { | ||
(cb) => { | ||
if (opt.format !== 'po' && opt.format !== 'gettext') return cb(); | ||
async.forEach(localFiles, (f, cb) => { | ||
const newFilePath = f.pathToLocalFile.substring(0, f.pathToLocalFile.lastIndexOf('.')) + '.po'; | ||
fs.readFile(f.pathToLocalFile, 'utf8', (err, data) => { | ||
if (err) return cb(err); | ||
try { | ||
const js = JSON.parse(data); | ||
if (opt.skipEmpty && Object.keys(js).length === 0) { | ||
return fs.unlink(f.pathToLocalFile, cb); | ||
} | ||
const splittedKey = f.pathToLocalFile.split('/'); | ||
const ns = splittedKey[splittedKey.length - 1]; | ||
const lng = splittedKey[splittedKey.length - 2]; | ||
const version = splittedKey[splittedKey.length - 3]; | ||
const projId = splittedKey[splittedKey.length - 4]; | ||
const options = { project: 'locize', language: lng }; | ||
i18nextToPo(lng, data, options) | ||
.then((res) => { | ||
fs.writeFile(newFilePath, res, 'utf8', (err) => { | ||
if (err) return cb(err); | ||
fs.unlink(f.pathToLocalFile, cb); | ||
}); | ||
}, (err) => cb(err)); | ||
} catch (err) { | ||
cb(err); | ||
} | ||
}); | ||
}, cb); | ||
}, | ||
(cb) => { | ||
if (opt.format !== 'csv') return cb(); | ||
@@ -156,0 +189,0 @@ |
{ | ||
"name": "locize-cli", | ||
"version": "3.4.3", | ||
"version": "3.5.0", | ||
"description": "locize cli to import locales", | ||
@@ -11,3 +11,3 @@ "main": "index.js", | ||
"android-string-resource": "1.1.0", | ||
"async": "2.5.0", | ||
"async": "2.6.0", | ||
"colors": "1.1.2", | ||
@@ -17,2 +17,3 @@ "commander": "2.11.0", | ||
"flat": "4.0.0", | ||
"i18next-conv": "5.0.0", | ||
"ini": "1.3.4", | ||
@@ -24,3 +25,3 @@ "mkdirp": "0.5.1", | ||
"devDependencies": { | ||
"eslint": "4.9.0" | ||
"eslint": "4.11.0" | ||
}, | ||
@@ -27,0 +28,0 @@ "scripts": { |
@@ -117,3 +117,3 @@ [![npm](https://img.shields.io/npm/v/locize-cli.svg)](https://npmjs.org/package/locize-cli) | ||
or add a format like (flat, android, xliff2, xlliff12) | ||
or add a format like (flat, android, xliff2, xlliff12, android, csv, po) | ||
@@ -120,0 +120,0 @@ ```sh |
Sorry, the diff of this file is not supported yet
40731
584
11
+ Addedi18next-conv@5.0.0
+ Addedansi-styles@3.2.1(transitive)
+ Addedasync@2.6.0(transitive)
+ Addedbluebird@3.7.2(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedgettext-parser@1.4.0(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedi18next-conv@5.0.0(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedlodash.get@4.4.2(transitive)
+ Addednode-gettext@2.1.0(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedpkginfo@0.4.1(transitive)
+ Addedsupports-color@5.5.0(transitive)
- Removedasync@2.5.0(transitive)
Updatedasync@2.6.0