Skip to content

Commit

Permalink
⬆️ Update h5i18n@0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zswang committed May 22, 2017
1 parent 780d873 commit ac4f89d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
14 changes: 6 additions & 8 deletions lib/gulp-h5i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* A mobile page of internationalization development framework
* @author
* zswang (http://weibo.com/zswang)
* @version 0.0.4
* @date 2017-05-18
* @version 0.0.5
* @date 2017-05-22
*/
var h5i18n_compiler = require('h5i18n/lib/compiler');
var h5i18n = require('h5i18n');
var through = require('through2');
var gutil = require('gulp-util');
var PluginError = require('gulp-util/lib/PluginError');
Expand Down Expand Up @@ -41,17 +41,15 @@ module.exports = function (options) {
return callback(createError(file, 'Streaming not supported'));
}
if (file.isBuffer()) {
var langs = new h5i18n.Languages(options.defaultLang);
var map;
if (options.map) {
map = options.map;
} else if (options.mapfile) {
map = JSON.parse(fs.readFileSync(options.mapfile));
}
var contents = h5i18n_compiler.Compiler.replace(file.contents, {
defaultLang: options.defaultLang,
locale: options.locale,
map: map,
});
langs.dictionary(map);
var contents = langs.replace(file.contents, options.locale);
file.contents = new Buffer(contents);
}
return callback(null, file);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-h5i18n",
"version": "0.0.4",
"version": "0.0.5",
"description": "A mobile page of internationalization development framework",
"main": "lib/gulp-h5i18n.js",
"scripts": {
Expand Down Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"gulp-util": "^3.0.8",
"h5i18n": "^0.5.0",
"h5i18n": "^0.6.0",
"through2": "^2.0.3"
},
"files": [
Expand Down
10 changes: 4 additions & 6 deletions src/gulp-h5i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'use strict';
/*</remove>*/

var h5i18n_compiler = require('h5i18n/lib/compiler');
var h5i18n = require('h5i18n');
var through = require('through2');
var gutil = require('gulp-util');
var PluginError = require('gulp-util/lib/PluginError');
Expand Down Expand Up @@ -59,18 +59,16 @@ module.exports = function (options) {
}

if (file.isBuffer()) {
var langs = new h5i18n.Languages(options.defaultLang);
var map;
if (options.map) {
map = options.map;
} else if (options.mapfile) {
map = JSON.parse(fs.readFileSync(options.mapfile));
}
langs.dictionary(map);

var contents = h5i18n_compiler.Compiler.replace(file.contents, {
defaultLang: options.defaultLang,
locale: options.locale,
map: map,
});
var contents = langs.replace(file.contents, options.locale);
file.contents = new Buffer(contents);
}
return callback(null, file);
Expand Down

0 comments on commit ac4f89d

Please sign in to comment.