Comparing version 2.2.0 to 2.3.0
@@ -0,1 +1,15 @@ | ||
<a name="2.3.0"></a> | ||
# [2.3.0](https://github.com/kazupon/vue-i18n/compare/v2.2.0...v2.3.0) (2015-11-26) | ||
### Bug Fixes | ||
* **index:** cannot work at Vue 1.0.10 later ([6fd543e](https://github.com/kazupon/vue-i18n/commit/6fd543e)), closes [#9](https://github.com/kazupon/vue-i18n/issues/9) | ||
### Features | ||
* **index:** support automatically install for standalone ([ada2673](https://github.com/kazupon/vue-i18n/commit/ada2673)) | ||
# v2.2.0 / 2015-09-16 | ||
@@ -2,0 +16,0 @@ |
/*! | ||
* vue-i18n v2.2.0 | ||
* vue-i18n v2.3.0 | ||
* (c) 2015 kazuya kawaguchi | ||
@@ -67,2 +67,3 @@ * Released under the MIT License. | ||
}); | ||
exports['default'] = install; | ||
@@ -76,3 +77,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
/** | ||
* plugin | ||
* install | ||
* | ||
@@ -83,3 +84,3 @@ * @param {Object} Vue | ||
exports['default'] = function (Vue) { | ||
function install(Vue) { | ||
var opts = arguments.length <= 1 || arguments[1] === undefined ? { lang: 'en', locales: {} } : arguments[1]; | ||
@@ -89,3 +90,3 @@ | ||
(0, _extend2['default'])(Vue, opts.locales); | ||
}; | ||
} | ||
@@ -112,2 +113,10 @@ /** | ||
} | ||
/** | ||
* install automaticlly | ||
*/ | ||
if (typeof window !== 'undefined' && window.Vue) { | ||
window.Vue.use(install); | ||
} | ||
module.exports = exports['default']; | ||
@@ -131,2 +140,6 @@ | ||
var _compare = __webpack_require__(3); | ||
var _compare2 = _interopRequireDefault(_compare); | ||
/** | ||
@@ -141,9 +154,9 @@ * extend | ||
exports['default'] = function (Vue, locales) { | ||
var path = Vue.parsers.path; | ||
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(path, key, lang, args) { | ||
function getVal(key, lang, args) { | ||
var value = key; | ||
try { | ||
var val = path.get(locales[lang], key) || locales[lang][key]; | ||
var val = getPath(locales[lang], key) || locales[lang][key]; | ||
value = (args ? (0, _format2['default'])(val, args) : val) || key; | ||
@@ -189,3 +202,3 @@ } catch (e) { | ||
return getVal(path, key, language, args); | ||
return getVal(key, language, args); | ||
}; | ||
@@ -254,2 +267,73 @@ | ||
/***/ }, | ||
/* 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']; | ||
/***/ } | ||
@@ -256,0 +340,0 @@ /******/ ]) |
/*! | ||
* vue-i18n v2.2.0 | ||
* vue-i18n v2.3.0 | ||
* (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 o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.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 o(e,t){Object.defineProperty(e,"lang",{get:function(){return t},set:function(e){t=e}})}Object.defineProperty(t,"__esModule",{value:!0});var u=r(1),a=n(u);t["default"]=function(e){var t=arguments.length<=1||void 0===arguments[1]?{lang:"en",locales:{}}:arguments[1];o(e.config,t.lang),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 o=r(2),u=n(o);t["default"]=function(e,t){function r(e,r,n,o){var a=r;try{var f=e.get(t[n],r)||t[n][r];a=(o?u["default"](f,o):f)||r}catch(i){a=r}return a}var n=e.parsers.path,o=e.util;return e.prototype.$t=function(t){for(var u=arguments.length,a=Array(u>1?u-1:0),f=1;u>f;f++)a[f-1]=arguments[f];if(!t)return"";var i=e.config.lang;return 1===a.length?o.isObject(a[0])||o.isArray(a[0])?a=a[0]:"string"==typeof a[0]&&(i=a[0]):2===a.length&&("string"==typeof a[0]&&(i=a[0]),(o.isObject(a[1])||o.isArray(a[1]))&&(a=a[1])),r(n,t,i,a)},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),o=1;t>o;o++)n[o-1]=arguments[o];return 1===n.length&&"object"==typeof n[0]&&(n=n[0]),n&&n.hasOwnProperty||(n={}),e.replace(r,function(t,r,o){var u=void 0;return"{"===e[o-1]&&"}"===e[o+t.length]?r:(u=n.hasOwnProperty(r)?n[r]:null,null===u||void 0===u?"":u)})},e.exports=t["default"]}])}); | ||
!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){var t=arguments.length<=1||void 0===arguments[1]?{lang:"en",locales:{}}:arguments[1];o(e.config,t.lang),(0,a["default"])(e,t.locales)}function o(e,t){Object.defineProperty(e,"lang",{get:function(){return t},set:function(e){t=e}})}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=u;var i=r(1),a=n(i);"undefined"!=typeof window&&window.Vue&&window.Vue.use(u),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),i=r(3),a=n(i);t["default"]=function(e,t){function r(e,r,u){var i=e;try{var a=n(t[r],e)||t[r][e];i=(u?(0,o["default"])(a,u):a)||e}catch(f){i=e}return i}var n=e.version&&-1===(0,a["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),i=1;n>i;i++)o[i-1]=arguments[i];if(!t)return"";var a=e.config.lang;return 1===o.length?u.isObject(o[0])||u.isArray(o[0])?o=o[0]:"string"==typeof o[0]&&(a=o[0]):2===o.length&&("string"==typeof o[0]&&(a=o[0]),(u.isObject(o[1])||u.isArray(o[1]))&&(o=o[1])),r(t,a,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),i=0;3>i;i++){var a=parseInt(u[i]||0,10),f=parseInt(o[i]||0,10);if(a>f)return 1;if(f>a)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"]}])}); |
{ | ||
"name": "vue-i18n", | ||
"description": "Internationalization plugin for Vue.js", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"author": { | ||
@@ -17,2 +17,3 @@ "name": "kazuya kawaguchi", | ||
"babel-plugin-espower": "^1.0.0", | ||
"cz-conventional-changelog": "^1.1.4", | ||
"eslint": "^1.3.1", | ||
@@ -35,4 +36,4 @@ "espower-babel": "^3.3.0", | ||
"mocha": "^2.3.1", | ||
"nightmare": "^1.6.5", | ||
"phantomjs": "^1.9.18", | ||
"nightmare": "^2.0.8", | ||
"phantomjs": "^1.9.19", | ||
"power-assert": "^1.0.0", | ||
@@ -61,3 +62,3 @@ "vue": "^0.12.0", | ||
"bundle": "webpack --config config/webpack.conf.js && webpack --config config/webpack.min.conf.js", | ||
"ci": "npm run coverage && npm run coveralls && npm run sauce && npm run e2e", | ||
"ci": "npm run lint && npm run coverage && npm run coveralls && npm run sauce", | ||
"clean": "rm -rf lib && rm -rf coverage && rm -rf dist", | ||
@@ -67,10 +68,17 @@ "coolkids": "VUE_I18N_TYPE=sauce SAUCE=batch1 karma start config/karma.conf.js", | ||
"coveralls": "VUE_I18N_TYPE=coveralls karma start config/karma.conf.js", | ||
"dist": "npm run build && npm run bundle", | ||
"e2e": "webpack-dev-server --quiet -h --config config/webpack.e2e.conf.js --content-base test/e2e & mocha -t 20000 --compilers js:espower-babel/guess test/e2e/test.js && kill $! || (kill $! && exit 1)", | ||
"ie": "VUE_I18N_TYPE=sauce SAUCE=batch2 karma start config/karma.conf.js", | ||
"lint": "eslint src test config", | ||
"lint": "eslint src test", | ||
"mobile": "VUE_I18N_TYPE=sauce SAUCE=batch3 karma start config/karma.conf.js", | ||
"sauce": "npm run coolkids && npm run ie && npm run mobile", | ||
"test": "karma start config/karma.conf.js", | ||
"test": "npm run ci", | ||
"unit": "npm run lint && karma start config/karma.conf.js", | ||
"watch": "babel src --out-dir lib --watch --source-maps-inline" | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "./node_modules/cz-conventional-changelog" | ||
} | ||
} | ||
} |
@@ -7,2 +7,3 @@ # vue-i18n | ||
[![Sauce Test Status](https://saucelabs.com/buildstatus/vue-i18n)](https://saucelabs.com/u/vue-i18n) | ||
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) | ||
@@ -14,6 +15,6 @@ | ||
# Requirements | ||
- works with Vue.js ^`0.12.0` | ||
- works with Vue.js `0.12.0`+ | ||
# Instllation | ||
# Installation | ||
@@ -32,2 +33,13 @@ ## npm | ||
When used in CommonJS, you must explicitly install the router via Vue.use(): | ||
```javascript | ||
var Vue = require('vue') | ||
var i18n = require('vue-validator') | ||
Vue.use(i18n, { ... }) | ||
``` | ||
You don't need to do this when using the standalone build because it installs itself automatically. | ||
# Usage | ||
@@ -162,3 +174,3 @@ | ||
lang: 'en', | ||
locals: { | ||
locales: { | ||
en: { | ||
@@ -180,3 +192,3 @@ ... | ||
### locals | ||
### locales | ||
Specify translate some local dictionary. | ||
@@ -187,6 +199,6 @@ | ||
# Configrations | ||
# Configuration | ||
## Vue.config.lang | ||
Get or set a global translation language code. Default by `en` string value. You can change the language of the global level dynamic translation in your application. | ||
Get or set a global translation language code. Default by `en` string value. You can change the language of the global level dynamic translation in your application. | ||
@@ -193,0 +205,0 @@ When specified with `lang` plugins option at `Vue.use`, `Vue.config.lang` is set that value. |
import format from './format' | ||
import compare from './compare' | ||
@@ -13,9 +14,11 @@ | ||
export default function (Vue, locales) { | ||
const path = Vue.parsers.path | ||
const getPath = (Vue.version && compare('1.0.8', Vue.version) === -1) | ||
? Vue.parsers.path.getPath | ||
: Vue.parsers.path.get | ||
const util = Vue.util | ||
function getVal (path, key, lang, args) { | ||
function getVal (key, lang, args) { | ||
let value = key | ||
try { | ||
let val = path.get(locales[lang], key) || locales[lang][key] | ||
let val = getPath(locales[lang], key) || locales[lang][key] | ||
value = (args ? format(val, args) : val) || key | ||
@@ -55,3 +58,3 @@ } catch (e) { | ||
return getVal(path, key, language, args) | ||
return getVal(key, language, args) | ||
} | ||
@@ -58,0 +61,0 @@ |
@@ -5,3 +5,3 @@ import extend from './extend' | ||
/** | ||
* plugin | ||
* install | ||
* | ||
@@ -12,3 +12,3 @@ * @param {Object} Vue | ||
export default function (Vue, opts = { lang: 'en', locales: {} }) { | ||
export default function install (Vue, opts = { lang: 'en', locales: {} }) { | ||
defineConfig(Vue.config, opts.lang) | ||
@@ -35,1 +35,10 @@ extend(Vue, opts.locales) | ||
} | ||
/** | ||
* install automaticlly | ||
*/ | ||
if (typeof window !== 'undefined' && window.Vue) { | ||
window.Vue.use(install) | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
25076
19
477
222
0
28