Bladeren bron

Minor fix for i18n.js

Gerald 10 jaren geleden
bovenliggende
commit
7ad3bf3a14
6 gewijzigde bestanden met toevoegingen van 11 en 10 verwijderingen
  1. 1 1
      gulpfile.js
  2. 4 3
      scripts/i18n.js
  3. 3 3
      src/_locales/cs/messages.json
  4. 1 1
      src/_locales/en/messages.json
  5. 1 1
      src/_locales/zh/messages.json
  6. 1 1
      src/options/view.js

+ 1 - 1
gulpfile.js

@@ -29,7 +29,7 @@ gulp.task('copy-files', function () {
     '!src/**/templates/**',
     '!src/**/templates',
     '!src/_locales/**',
-  ], {base:'src'})
+  ])
   .pipe(cssFilter)
   .pipe(minifyCss())
   .pipe(cssFilter.restore)

+ 4 - 3
scripts/i18n.js

@@ -13,7 +13,8 @@ function Locale(lang, path, base) {
 }
 Locale.prototype.read = function () {
   return new Promise((resolve, reject) => {
-    fs.readFile(this.base + '/' + this.path, (err, data) => err ? reject(err) : resolve(data));
+    const file = this.base + '/' + this.path;
+    fs.readFile(file, 'utf8', (err, data) => err ? reject(err) : resolve(data));
   }).then((data) => {
     const desc = {};
     data = JSON.parse(data);
@@ -63,7 +64,7 @@ Locales.prototype.load = function () {
 };
 Locales.prototype.getData = function (lang, options) {
   options = options || {};
-  let data = {};
+  const data = {};
   const langData = this.data[lang];
   const defaultData = options.useDefaultLang && lang != this.defaultLang && this.data[this.defaultLang];
   for (let key in this.desc) {
@@ -83,7 +84,7 @@ Locales.prototype.dump = function (options) {
     const string = JSON.stringify(data, null, 2);
     return new gutil.File({
       base: '',
-      path: `${this.prefix}/${lang}/messages.json`,
+      path: this.data[lang].path,
       contents: new Buffer(string),
     });
   });

+ 3 - 3
src/_locales/cs/messages.json

@@ -196,7 +196,7 @@
     "message": "Související odkazy: "
   },
   "anchorSupportPage": {
-    "description": "Odkaz na stránku podpory Violentmonkey.",
+    "description": "Link to the support page of Violentmonkey.",
     "message": "<a href=https://github.com/gera2ld/Violentmonkey/wiki target=_blank>Violentmonkey</a>"
   },
   "labelDonate": {
@@ -404,7 +404,7 @@
     "message": "Vše"
   },
   "labelAutoReloadCurrentTab": {
-    "description": "Option to reload current tab after a script is switched on or off from the popup menu.",
+    "description": "Option to reload current tab after a script is switched on or off from menu.",
     "message": "Znovu načíst současný list po zapnutí či vypnutí skriptu z nabídky."
   },
   "hintInjectModeNormal": {
@@ -415,4 +415,4 @@
     "description": "Hint to explain the advanced injection mode.",
     "message": ""
   }
-}
+}

+ 1 - 1
src/_locales/en/messages.json

@@ -415,4 +415,4 @@
     "description": "Hint to explain the advanced injection mode.",
     "message": "Works in most pages, actually a hack"
   }
-}
+}

+ 1 - 1
src/_locales/zh/messages.json

@@ -415,4 +415,4 @@
     "description": "Hint to explain the advanced injection mode.",
     "message": "不走寻常路,可以在大部分页面成功注入"
   }
-}
+}

+ 1 - 1
src/options/view.js

@@ -15,9 +15,9 @@ var ScriptView = BaseView.extend({
   initialize: function () {
     var _this = this;
     _this.model.set('_icon', DEFAULT_ICON);
-    BaseView.prototype.initialize.call(_this);
     _this.listenTo(_this.model, 'change', _this.render);
     _this.listenTo(_this.model, 'remove', _this.onRemoved);
+    BaseView.prototype.initialize.call(_this);
   },
   loadIcon: function () {
     var _this = this;