diff --git a/CHANGELOG.md b/CHANGELOG.md index 60132a7f2..790d7749e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ + +## [2.3.2](https://github.com/kazupon/vue-i18n/compare/v2.3.1...v2.3.2) (2015-12-09) + + +### Features + +* **bundle:** more compact the vue-i18n distribution file ([2f32ecc](https://github.com/kazupon/vue-i18n/commit/2f32ecc)) + + + ## [2.3.1](https://github.com/kazupon/vue-i18n/compare/v2.3.0...v2.3.1) (2015-12-01) diff --git a/dist/vue-i18n.js b/dist/vue-i18n.js index 76001c858..c98baff73 100644 --- a/dist/vue-i18n.js +++ b/dist/vue-i18n.js @@ -1,324 +1,225 @@ /*! - * vue-i18n v2.3.1 + * vue-i18n v2.3.2 * (c) 2015 kazuya kawaguchi * Released under the MIT License. */ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define([], factory); - else if(typeof exports === 'object') - exports["vue-i18n"] = factory(); - else - root["vue-i18n"] = factory(); -})(this, function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; - -/******/ // The require function -/******/ function __webpack_require__(moduleId) { - -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) -/******/ return installedModules[moduleId].exports; - -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ exports: {}, -/******/ id: moduleId, -/******/ loaded: false -/******/ }; - -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); - -/******/ // Flag the module as loaded -/******/ module.loaded = true; - -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } - - -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; - -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; - -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; - -/******/ // Load entry module and return exports -/******/ return __webpack_require__(0); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _extend = __webpack_require__(1); - - var _extend2 = _interopRequireDefault(_extend); - - /** - * plugin - * - * @param {Object} Vue - * @param {Object} opts - */ - - exports['default'] = function (Vue) { - var opts = arguments.length <= 1 || arguments[1] === undefined ? { lang: 'en', locales: {} } : arguments[1]; - - defineConfig(Vue.config, opts.lang); - (0, _extend2['default'])(Vue, opts.locales); - }; - - /** - * defineConfig - * - * This function define `lang` property to `Vue.config`. - * - * @param {Object} config - * @param {String} lang - * @private - */ - - function defineConfig(config, lang) { - Object.defineProperty(config, 'lang', { - get: function get() { - return lang; - }, - set: function set(val) { - lang = val; - } - }); - } - module.exports = exports['default']; - -/***/ }, -/* 1 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _format = __webpack_require__(2); - - var _format2 = _interopRequireDefault(_format); - - var _compare = __webpack_require__(3); - - var _compare2 = _interopRequireDefault(_compare); - - /** - * extend - * - * @param {Vue} Vue - * @param {Object} locales - * @return {Vue} - */ - - exports['default'] = function (Vue, locales) { - var getPath = Vue.version && (0, _compare2['default'])('1.0.8', Vue.version) === -1 ? Vue.parsers.path.getPath : Vue.parsers.path.get; - var util = Vue.util; - - function getVal(key, lang, args) { - var value = key; - try { - var val = getPath(locales[lang], key) || locales[lang][key]; - value = (args ? (0, _format2['default'])(val, args) : val) || key; - } catch (e) { - value = key; - } - return value; - } - - /** - * $t - * - * @param {String} key - * @param {Array} ...args - * @return {String} - */ - - Vue.prototype.$t = function (key) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - if (!key) { - return ''; - } - - var language = Vue.config.lang; - if (args.length === 1) { - if (util.isObject(args[0]) || util.isArray(args[0])) { - args = args[0]; - } else if (typeof args[0] === 'string') { - language = args[0]; - } - } else if (args.length === 2) { - if (typeof args[0] === 'string') { - language = args[0]; - } - if (util.isObject(args[1]) || util.isArray(args[1])) { - args = args[1]; - } - } - - return getVal(key, language, args); - }; - - return Vue; - }; - - module.exports = exports['default']; - -/***/ }, -/* 2 */ -/***/ function(module, exports) { - - /** - * String format template - * - Inspired: - * https://github.com/Matt-Esch/string-template/index.js - */ - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - var RE_NARGS = /\{([0-9a-zA-Z]+)\}/g; - - /** - * template - * - * @param {String} string - * @param {Array} ...args - * @return {String} - */ - - exports['default'] = function (string) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - if (args.length === 1 && typeof args[0] === 'object') { - args = args[0]; - } - - if (!args || !args.hasOwnProperty) { - args = {}; - } - - return string.replace(RE_NARGS, function (match, i, index) { - var result = undefined; - - if (string[index - 1] === '{' && string[index + match.length] === '}') { - return i; - } else { - result = args.hasOwnProperty(i) ? args[i] : null; - if (result === null || result === undefined) { - return ''; - } - - return result; - } - }); - }; - - module.exports = exports['default']; - -/***/ }, -/* 3 */ -/***/ function(module, exports) { - - /** - * Version compare - * - Inspired: - * https://github.com/omichelsen/compare-versions - */ - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - var PATCH_PATTERN = /-([\w-.]+)/; - - function split(v) { - var temp = v.split('.'); - var arr = temp.splice(0, 2); - arr.push(temp.join('.')); - return arr; - } - - /** - * compare - * - * @param {String} v1 - * @param {String} v2 - * @return {Number} - */ - - exports['default'] = function (v1, v2) { - var s1 = split(v1); - var s2 = split(v2); - - for (var i = 0; i < 3; i++) { - var n1 = parseInt(s1[i] || 0, 10); - var n2 = parseInt(s2[i] || 0, 10); - - if (n1 > n2) { - return 1; - } - if (n2 > n1) { - return -1; - } - } - - if ((s1[2] + s2[2] + '').indexOf('-') > -1) { - var p1 = (PATCH_PATTERN.exec(s1[2]) || [''])[0]; - var p2 = (PATCH_PATTERN.exec(s2[2]) || [''])[0]; - - if (p1 === '') { - return 1; - } - if (p2 === '') { - return -1; - } - if (p1 > p2) { - return 1; - } - if (p2 > p1) { - return -1; - } - } - - return 0; - }; - - module.exports = exports['default']; - -/***/ } -/******/ ]) -}); -; \ No newline at end of file +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + global.VueI18n = factory(); +}(this, function () { 'use strict'; + + var babelHelpers = {}; + + babelHelpers.typeof = function (obj) { + return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; + }; + + babelHelpers; + /** + * String format template + * - Inspired: + * https://github.com/Matt-Esch/string-template/index.js + */ + + var RE_NARGS = /\{([0-9a-zA-Z]+)\}/g; + + /** + * template + * + * @param {String} string + * @param {Array} ...args + * @return {String} + */ + + function format (string) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + if (args.length === 1 && babelHelpers.typeof(args[0]) === 'object') { + args = args[0]; + } + + if (!args || !args.hasOwnProperty) { + args = {}; + } + + return string.replace(RE_NARGS, function (match, i, index) { + var result = undefined; + + if (string[index - 1] === '{' && string[index + match.length] === '}') { + return i; + } else { + result = args.hasOwnProperty(i) ? args[i] : null; + if (result === null || result === undefined) { + return ''; + } + + return result; + } + }); + } + + /** + * Version compare + * - Inspired: + * https://github.com/omichelsen/compare-versions + */ + + var PATCH_PATTERN = /-([\w-.]+)/; + + function split(v) { + var temp = v.split('.'); + var arr = temp.splice(0, 2); + arr.push(temp.join('.')); + return arr; + } + + /** + * compare + * + * @param {String} v1 + * @param {String} v2 + * @return {Number} + */ + + function compare (v1, v2) { + var s1 = split(v1); + var s2 = split(v2); + + for (var i = 0; i < 3; i++) { + var n1 = parseInt(s1[i] || 0, 10); + var n2 = parseInt(s2[i] || 0, 10); + + if (n1 > n2) { + return 1; + } + if (n2 > n1) { + return -1; + } + } + + if ((s1[2] + s2[2] + '').indexOf('-') > -1) { + var p1 = (PATCH_PATTERN.exec(s1[2]) || [''])[0]; + var p2 = (PATCH_PATTERN.exec(s2[2]) || [''])[0]; + + if (p1 === '') { + return 1; + } + if (p2 === '') { + return -1; + } + if (p1 > p2) { + return 1; + } + if (p2 > p1) { + return -1; + } + } + + return 0; + } + + /** + * extend + * + * @param {Vue} Vue + * @param {Object} locales + * @return {Vue} + */ + + function extend (Vue, locales) { + var getPath = Vue.version && compare('1.0.8', Vue.version) === -1 ? Vue.parsers.path.getPath : Vue.parsers.path.get; + var util = Vue.util; + + function getVal(key, lang, args) { + var value = key; + try { + var val = getPath(locales[lang], key) || locales[lang][key]; + value = (args ? format(val, args) : val) || key; + } catch (e) { + value = key; + } + return value; + } + + /** + * $t + * + * @param {String} key + * @param {Array} ...args + * @return {String} + */ + + Vue.prototype.$t = function (key) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + if (!key) { + return ''; + } + + var language = Vue.config.lang; + if (args.length === 1) { + if (util.isObject(args[0]) || util.isArray(args[0])) { + args = args[0]; + } else if (typeof args[0] === 'string') { + language = args[0]; + } + } else if (args.length === 2) { + if (typeof args[0] === 'string') { + language = args[0]; + } + if (util.isObject(args[1]) || util.isArray(args[1])) { + args = args[1]; + } + } + + return getVal(key, language, args); + }; + + return Vue; + } + + /** + * plugin + * + * @param {Object} Vue + * @param {Object} opts + */ + + function plugin(Vue) { + var opts = arguments.length <= 1 || arguments[1] === undefined ? { lang: 'en', locales: {} } : arguments[1]; + + defineConfig(Vue.config, opts.lang); + extend(Vue, opts.locales); + } + + /** + * defineConfig + * + * This function define `lang` property to `Vue.config`. + * + * @param {Object} config + * @param {String} lang + * @private + */ + + function defineConfig(config, lang) { + Object.defineProperty(config, 'lang', { + get: function get() { + return lang; + }, + set: function set(val) { + lang = val; + } + }); + } + + plugin.version = '2.3.2'; + + return plugin; + +})); \ No newline at end of file diff --git a/dist/vue-i18n.min.js b/dist/vue-i18n.min.js index e0cc2f8ed..3d94ea14b 100644 --- a/dist/vue-i18n.min.js +++ b/dist/vue-i18n.min.js @@ -1,6 +1,6 @@ /*! - * vue-i18n v2.3.1 + * vue-i18n v2.3.2 * (c) 2015 kazuya kawaguchi * Released under the MIT License. */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["vue-i18n"]=t():e["vue-i18n"]=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var u=r[n]={exports:{},id:n,loaded:!1};return e[n].call(u.exports,u,u.exports,t),u.loaded=!0,u.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function u(e,t){Object.defineProperty(e,"lang",{get:function(){return t},set:function(e){t=e}})}Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),a=n(o);t["default"]=function(e){var t=arguments.length<=1||void 0===arguments[1]?{lang:"en",locales:{}}:arguments[1];u(e.config,t.lang),(0,a["default"])(e,t.locales)},e.exports=t["default"]},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var u=r(2),o=n(u),a=r(3),f=n(a);t["default"]=function(e,t){function r(e,r,u){var a=e;try{var f=n(t[r],e)||t[r][e];a=(u?(0,o["default"])(f,u):f)||e}catch(i){a=e}return a}var n=e.version&&-1===(0,f["default"])("1.0.8",e.version)?e.parsers.path.getPath:e.parsers.path.get,u=e.util;return e.prototype.$t=function(t){for(var n=arguments.length,o=Array(n>1?n-1:0),a=1;n>a;a++)o[a-1]=arguments[a];if(!t)return"";var f=e.config.lang;return 1===o.length?u.isObject(o[0])||u.isArray(o[0])?o=o[0]:"string"==typeof o[0]&&(f=o[0]):2===o.length&&("string"==typeof o[0]&&(f=o[0]),(u.isObject(o[1])||u.isArray(o[1]))&&(o=o[1])),r(t,f,o)},e},e.exports=t["default"]},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=/\{([0-9a-zA-Z]+)\}/g;t["default"]=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),u=1;t>u;u++)n[u-1]=arguments[u];return 1===n.length&&"object"==typeof n[0]&&(n=n[0]),n&&n.hasOwnProperty||(n={}),e.replace(r,function(t,r,u){var o=void 0;return"{"===e[u-1]&&"}"===e[u+t.length]?r:(o=n.hasOwnProperty(r)?n[r]:null,null===o||void 0===o?"":o)})},e.exports=t["default"]},function(e,t){"use strict";function r(e){var t=e.split("."),r=t.splice(0,2);return r.push(t.join(".")),r}Object.defineProperty(t,"__esModule",{value:!0});var n=/-([\w-.]+)/;t["default"]=function(e,t){for(var u=r(e),o=r(t),a=0;3>a;a++){var f=parseInt(u[a]||0,10),i=parseInt(o[a]||0,10);if(f>i)return 1;if(i>f)return-1}if((u[2]+o[2]+"").indexOf("-")>-1){var s=(n.exec(u[2])||[""])[0],l=(n.exec(o[2])||[""])[0];if(""===s)return 1;if(""===l)return-1;if(s>l)return 1;if(l>s)return-1}return 0},e.exports=t["default"]}])}); \ No newline at end of file +!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):n.VueI18n=r()}(this,function(){"use strict";function n(n){for(var r=arguments.length,e=Array(r>1?r-1:0),t=1;r>t;t++)e[t-1]=arguments[t];return 1===e.length&&"object"===u["typeof"](e[0])&&(e=e[0]),e&&e.hasOwnProperty||(e={}),n.replace(a,function(r,t,o){var i=void 0;return"{"===n[o-1]&&"}"===n[o+r.length]?t:(i=e.hasOwnProperty(t)?e[t]:null,null===i||void 0===i?"":i)})}function r(n){var r=n.split("."),e=r.splice(0,2);return e.push(r.join(".")),e}function e(n,e){for(var t=r(n),o=r(e),i=0;3>i;i++){var u=parseInt(t[i]||0,10),a=parseInt(o[i]||0,10);if(u>a)return 1;if(a>u)return-1}if((t[2]+o[2]+"").indexOf("-")>-1){var s=(f.exec(t[2])||[""])[0],c=(f.exec(o[2])||[""])[0];if(""===s)return 1;if(""===c)return-1;if(s>c)return 1;if(c>s)return-1}return 0}function t(r,t){function o(r,e,o){var u=r;try{var a=i(t[e],r)||t[e][r];u=(o?n(a,o):a)||r}catch(f){u=r}return u}var i=r.version&&-1===e("1.0.8",r.version)?r.parsers.path.getPath:r.parsers.path.get,u=r.util;return r.prototype.$t=function(n){for(var e=arguments.length,t=Array(e>1?e-1:0),i=1;e>i;i++)t[i-1]=arguments[i];if(!n)return"";var a=r.config.lang;return 1===t.length?u.isObject(t[0])||u.isArray(t[0])?t=t[0]:"string"==typeof t[0]&&(a=t[0]):2===t.length&&("string"==typeof t[0]&&(a=t[0]),(u.isObject(t[1])||u.isArray(t[1]))&&(t=t[1])),o(n,a,t)},r}function o(n){var r=arguments.length<=1||void 0===arguments[1]?{lang:"en",locales:{}}:arguments[1];i(n.config,r.lang),t(n,r.locales)}function i(n,r){Object.defineProperty(n,"lang",{get:function(){return r},set:function(n){r=n}})}var u={};u["typeof"]=function(n){return n&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n};var a=/\{([0-9a-zA-Z]+)\}/g,f=/-([\w-.]+)/;return o.version="2.3.2",o}); \ No newline at end of file diff --git a/package.json b/package.json index d55b015a8..e35e9aeb9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vue-i18n", "description": "Internationalization plugin for Vue.js", - "version": "2.3.1", + "version": "2.3.2", "author": { "name": "kazuya kawaguchi", "email": "kawakazu80@gmail.com" diff --git a/src/index.js b/src/index.js index 22d4da680..3480962c3 100644 --- a/src/index.js +++ b/src/index.js @@ -31,6 +31,6 @@ function defineConfig (config, lang) { }) } -plugin.version = '2.3.1' +plugin.version = '2.3.2' export default plugin