UNPKG

1.77 kBJavaScriptView Raw
1'use strict';
2
3var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
4
5function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7var path = require('path');
8var fs = require('fs');
9var propertytojson = require('fz-propertytojson').default;
10
11var i18nPlugin = function () {
12 function i18nPlugin(options) {
13 _classCallCheck(this, i18nPlugin);
14
15 this.targetPath = path.join(options.appPath, options.context, 'i18n');
16 this.i18nPropPath = path.join(options.appPath, options.context, 'properties');
17 this.baseProperty = options.baseProperty ? path.join(options.appPath, options.context, options.baseProperty) : path.join(options.appPath, options.context, '/properties/ApplicationResources_en_US.properties');
18 this.i18nObjPath = path.join(appPath, 'node_modules', '.cache', 'i18nkeys.json');
19 }
20
21 _createClass(i18nPlugin, [{
22 key: 'apply',
23 value: function apply(compiler) {
24 var _this = this;
25
26 compiler.plugin('done', function (compilation, callback) {
27 propertytojson(_this.i18nPropPath, _this.targetPath, _this.baseProperty, _this.i18nObjPath);
28 });
29 }
30 }]);
31
32 return i18nPlugin;
33}();
34
35module.exports = i18nPlugin;
\No newline at end of file