New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gulp-i18n-leverage

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-i18n-leverage - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

package.json
{
"name": "gulp-i18n-leverage",
"version": "1.0.1",
"version": "1.0.2",
"description": "Merge changes in default JSON into localized JSON for i18n-behavior",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -150,2 +150,59 @@ [![Build Status](https://travis-ci.org/t2ym/gulp-i18n-leverage.svg?branch=master)](https://travis-ci.org/t2ym/gulp-i18n-leverage)

### Import Xliff task (experimental)
#### Note: This task has to be processed before [Leverage task with unbundle](#leverage-task-with-unbundle) to pick up outputs of this task.
#### Input:
- Next Xliff files in source
- Current bundle JSON files in source (as output templates)
#### Output:
- Overwritten bundle JSON files in source
```javascript
var gulp = require('gulp');
var JSONstringify = require('json-stringify-safe');
var through = require('through2');
var xliff2bundlejson = require('xliff2bundlejson');
// Import bundles.{lang}.xlf
gulp.task('import-xliff', function () {
var xliffPath = path.join('app', 'xliff');
var x2j = new xliff2bundlejson({
cleanJSON: true,
decorateJSON: true,
polymer: true
});
return gulp.src([
'app/**/xliff/bundle.*.xlf'
])
.pipe(through.obj(function (file, enc, callback) {
var bundle, bundlePath;
var base = path.basename(file.path, '.xlf').match(/^(.*)[.]([^.]*)$/);
var xliff = String(file.contents);
if (base) {
try {
bundlePath = path.join(file.base, 'locales', 'bundle.' + base[2] + '.json');
bundle = JSON.parse(stripBom(fs.readFileSync(bundlePath, 'utf8')));
x2j.parseXliff(xliff, { bundle: bundle }, function (output) {
file.contents = new Buffer(JSONstringify(output, null, 2));
file.path = bundlePath;
callback(null, file);
});
}
catch (ex) {
callback(null, file);
}
}
else {
callback(null, file);
}
}))
.pipe(gulp.dest('app'))
.pipe($.size({
title: 'import-xliff'
}));
});
```
### Leverage task

@@ -268,2 +325,53 @@

### Export Xliff task (experimental)
#### Note: This task has to be processed after [Bundles task](#bundles). `srcLanguage` must match with the default language of the app.
#### Input:
- Next bundles object in gulpfile.js
#### Output:
- bundle.{lang}.xlf Xliff in dest/xliff
```javascript
var gulp = require('gulp');
var through = require('through2');
var xliff2bundlejson = require('xliff2bundlejson');
// Generate bundles.{lang}.xlf
gulp.task('export-xliff', function (callback) {
var srcLanguage = 'en';
var xliffPath = dist('xliff');
var x2j = new xliff2bundlejson({
cleanJSON: true,
decorateJSON: true,
polymer: true
});
var promises = [];
try {
fs.mkdirSync(xliffPath);
}
catch (e) {
}
for (var lang in bundles) {
if (lang) {
(function (destLanguage) {
promises.push(new Promise(function (resolve, reject) {
x2j.parseJSON(bundles, {
srcLanguage: srcLanguage,
destLanguage: destLanguage,
maxDepth: 32
}, function (output) {
fs.writeFile(path.join(xliffPath, 'bundle.' + destLanguage + '.xlf'), output, resolve);
});
}));
})(lang);
}
}
Promise.all(promises).then(function (outputs) {
callback();
});
});
```
### Feedback task

@@ -270,0 +378,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc