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.0 to 1.0.1

2

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

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

[![Build Status](https://travis-ci.org/t2ym/gulp-i18n-leverage.svg?branch=master)](https://travis-ci.org/t2ym/gulp-i18n-leverage)
[![Coverage Status](https://coveralls.io/repos/github/t2ym/gulp-i18n-leverage/badge.svg?branch=master)](https://coveralls.io/github/t2ym/gulp-i18n-leverage?branch=master)
[![npm](https://img.shields.io/npm/v/gulp-i18n-leverage.svg)](https://www.npmjs.com/package/gulp-i18n-leverage)

@@ -179,2 +180,51 @@ # gulp-i18n-leverage

### Leverage task with unbundle
#### Note: If translation is done in locales/bundle.*.json in source for all the elements, contents of per-element json are discarded and replaced with those in the bundle. The per-element json files will be translated in [feedback task](#feedback-task).
#### Input:
- Current localized bundle JSON files in source
- Current localized JSON files in source (contents are discarded)
- Current default JSON files in source
- Next default JSON files in dist
#### Output:
- Next localized JSON files in dist
- Bundles object in gulpfile.js
```javascript
var gulp = require('gulp');
var i18nLeverage = require('gulp-i18n-leverage');
var through = require('through2'); // for unbundle
var stripBom = require('strip-bom'); // for unbundle
var bundles = {};
gulp.task('leverage', function () {
return gulp.src([ 'app/**/locales/*.json', '!app/**/locales/bundle.*.json' ]) // exclude bundles
// replace contents with unbundled ones
.pipe(through.obj(function (file, enc, callback) {
var bundle, base = path.basename(file.path, '.json').match(/^(.*)[.]([^.]*)$/);
if (base) {
try {
bundle = JSON.parse(stripBom(fs.readFileSync(path.join(file.base, 'locales', 'bundle.' + base[2] + '.json'), 'utf8')));
if (bundle[base[1]]) {
file.contents = new Buffer(JSONstringify(bundle[base[1]], null, 2));
}
}
catch (ex) {}
}
callback(null, file);
}))
.pipe(i18nLeverage({
jsonSpace: 2, // JSON format with 2 spaces
srcPath: 'app', // path to source root
distPath: 'dist', // path to dist root to fetch next default JSON files
finalize: false, // keep meta information
bundles: bundles // output bundles object
}))
.pipe(gulp.dest('dist')); // path to output next localized JSON files
});
```
### Bundles task

@@ -230,2 +280,3 @@

- Overwritten default JSON files in source
- Overwritten bundle JSON files in source [if translation is done in bundles](#leverage-task-with-unbundle)

@@ -242,3 +293,6 @@ Outputs are ready to commit in the repository

// Copy from dist
var locales = gulp.src([ 'dist/**/locales/*.json', '!dist/locales/bundle.*.json'])
var locales = gulp.src([
'dist/**/locales/*.json',
'!dist/locales/bundle.*.json' // Remove this item if translation is done in bundles
])
.pipe(gulp.dest('app'));

@@ -245,0 +299,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