Skip to content

mikoda-es/gulp-i18next-translate

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-i18next-translate

Inspired From

gulp-translation

The main source code is inspired from this project. Big thanks to them.

Installation

$ npm install git+ssh:https://[email protected]/patw0929/gulp-i18next-translate.git --save-dev

Usage

The strings in HTML which needed to be translated should be wrapped by special characters (defined in functions array):

<h1>__('Homepage')</h1>
__('http:https://patw.idv.tw')
<p>__('Will not be replaced')</p>

And the translation mapping json file is like this:

{
  "Homepage": "首頁",
  "Name": "姓名",
  "http:https://patw.idv.tw": "http:https://patw.idv.tw/blog/",
  "Will not be replaced": ""
}

It can generated by i18next-parser.

Through gulp task, we can make strings to be translated:

var translate = require('gulp-i18next-translate');

gulp.task('i18next-translate', function() {
  gulp.src('./src/*.html')
  .pipe(translate({
    functions: ['__', '_e'],
    locale: 'locales/*/translation.json'
  }))
  .pipe(gulp.dest('translated'));
});

Finally you can generate translated HTML files like:

<h1>首頁</h1>
http:https://patw.idv.tw/blog/
<p>Will not be replaced</p>

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • JavaScript 100.0%