@kazupon/vue-i18n-loader
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -0,1 +1,17 @@ | ||
<a name="0.4.1"></a> | ||
## [0.4.1](https://github.com/kazupon/vue-i18n-loader/compare/v0.3.0...v0.4.1) (2019-07-31) | ||
### :bug: Bug Fixes | ||
* fix dist file ([98c4b7d](https://github.com/kazupon/vue-i18n-loader/commit/98c4b7d)) | ||
### :star: New Features | ||
* support lang attribute ([36c62a5](https://github.com/kazupon/vue-i18n-loader/commit/36c62a5)), closes [#52](https://github.com/kazupon/vue-i18n-loader/issues/52) | ||
* support locale attr for i18n custom blocks ([be2bcc2](https://github.com/kazupon/vue-i18n-loader/commit/be2bcc2)), closes [#11](https://github.com/kazupon/vue-i18n-loader/issues/11) | ||
<a name="0.4.0"></a> | ||
@@ -2,0 +18,0 @@ # [0.4.0](https://github.com/kazupon/vue-i18n-loader/compare/v0.3.0...v0.4.0) (2019-07-22) |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var querystring_1 = require("querystring"); | ||
var json5_1 = __importDefault(require("json5")); | ||
var js_yaml_1 = __importDefault(require("js-yaml")); | ||
var loader = function (source, sourceMap) { | ||
@@ -23,11 +28,4 @@ if (this.version && Number(this.version) >= 2) { | ||
var _a; | ||
var code = ''; | ||
var value = typeof source === 'string' | ||
? JSON.parse(source) | ||
: Buffer.isBuffer(source) | ||
? JSON.parse(source.toString()) | ||
: null; | ||
if (value === null) { | ||
throw new Error('invalid source!'); | ||
} | ||
var data = convert(source, query.lang); | ||
var value = JSON.parse(data); | ||
if (query.locale && typeof query.locale === 'string') { | ||
@@ -40,5 +38,19 @@ value = Object.assign({}, (_a = {}, _a[query.locale] = value, _a)); | ||
.replace(/\\/g, '\\\\'); | ||
var code = ''; | ||
code += "function (Component) {\n Component.options.__i18n = Component.options.__i18n || []\n Component.options.__i18n.push('" + value.replace(/\u0027/g, '\\u0027') + "')\n delete Component.options._Ctor\n}\n"; | ||
return code; | ||
} | ||
function convert(source, lang) { | ||
var value = Buffer.isBuffer(source) ? source.toString() : source; | ||
switch (lang) { | ||
case 'yaml': | ||
case 'yml': | ||
var data = js_yaml_1.default.safeLoad(value); | ||
return JSON.stringify(data, undefined, '\t'); | ||
case 'json5': | ||
return JSON.stringify(json5_1.default.parse(value)); | ||
default: | ||
return value; | ||
} | ||
} | ||
exports.default = loader; |
{ | ||
"name": "@kazupon/vue-i18n-loader", | ||
"description": "vue-i18n loader for custom blocks", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "kazuya kawaguchi", |
13852
107