gulp-ng-json2translate

Inspired by grunt-json-angular-translate. Wrap json file as angular translate module

Usage no npm install needed!

<script type="module">
  import gulpNgJson2translate from 'https://cdn.skypack.dev/gulp-ng-json2translate';
</script>

README

gulp-ng-json2translate

Built with Gulp

Plugin that wraps json as an angular translate module.

Inspired by https://github.com/shahata/grunt-json-angular-translate.

What is the result?

See here

Install

npm install gulp-ng-json2translate

Usage

var gulp=require('gulp');

var json2translate=require('gulp-ng-json2translate');
var concat=require('gulp-concat');

gulp.task('locale',function(){
    return gulp.src('./locale/*.json')
                .pipe(json2translate({
                    moduleName:'translations'
                }))
                .pipe(gulp.dest('./build/'));
});

options.moduleName

Type: Sting Default: translations

The name of the generated AngularJS module.

options.extractLanguage

Type: Function

Custom function to retrieve language out of file name.

The default function can retrieve the language from files like that:

  1. message_en.json
  2. message-en.json
  3. message.en.json

options.hasPreferredLanguage

Type: Boolean Default: true

The flag that indicates if there will be preferred language statement at the output file.

Tests

npm test

License

Licensed under the MIT license.