Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-i18n

Package Overview
Dependencies
Maintainers
1
Versions
355
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-i18n - npm Package Compare versions

Comparing version 0.11.0 to 1.0.0

auth.py

2

bower.json

@@ -5,3 +5,3 @@ {

"description": "Internationalization plugin of Vue.js",
"version": "0.11.0",
"version": "1.0.0",
"homepage": "https://github.com/kazupon/vue-i18n",

@@ -8,0 +8,0 @@ "authors": [

{
"name": "vue-i18n",
"repo": "kazupon/vue-i18n",
"version": "0.11.0",
"version": "1.0.0",
"description": "Internationalization plugin of Vue.js",

@@ -14,5 +14,3 @@ "license": "MIT",

"dependencies": {},
"development": {
"yyx990803/vue": "^0.11.0-rc"
},
"development": {},
"scripts": [

@@ -19,0 +17,0 @@ "index.js"

@@ -1,108 +0,116 @@

;(function(){
/**
* Require the module at `name`.
*
* @param {String} name
* @return {Object} exports
* @api public
* vue-i18n v1.0.0
* (c) 2015 kazuya kawaguchi
* Released under the MIT License.
*/
function require(name) {
var module = require.modules[name];
if (!module) throw new Error('failed to require "' + name + '"');
(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__) {
if (!('exports' in module) && typeof module.definition === 'function') {
module.client = module.component = true;
module.definition.call(this, module.exports = {}, module);
delete module.definition;
}
/**
* Expose internationalization plugin
*
* @param {Object} Vue
* @param {Object} opts
*/
return module.exports;
}
module.exports = function (Vue, opts) {
opts = opts || {}
var lang = opts.lang || 'en'
var locales = opts.locales || opts.resources || {}
/**
* Registered modules.
*/
// for Vue 0.11.4 later
try {
var path = Vue.parsers.path
Vue.prototype.$t = function (key) {
return key ? (path.get(locales[lang], key) || key) : ''
}
} catch (e) {
Vue.utils.warn('not support $t in this Vue version')
}
require.modules = {};
Vue.t = function (key) {
var ret = key || ''
var locale = locales[lang]
if (key && locale) {
var namespaces = key.split('.')
for (var i = 0; i < namespaces.length; i++) {
locale = locale[namespaces[i]]
if (!locale) {
ret = key
break
} else {
ret = locale
}
}
}
return ret
}
/**
* Register module at `name` with callback `definition`.
*
* @param {String} name
* @param {Function} definition
* @api private
*/
Vue.directive('t', {
isLiteral: true,
bind: function () {
if (this.el.nodeType !== 1) { return }
require.register = function (name, definition) {
require.modules[name] = {
definition: definition
};
};
this.el.textContent = Vue.t(this.expression)
}
})
}
/**
* Define a module's exports immediately with `exports`.
*
* @param {String} name
* @param {Generic} exports
* @api private
*/
require.define = function (name, exports) {
require.modules[name] = {
exports: exports
};
};
require.register("vue-i18n", function (exports, module) {
/**
* Expose internationalization plugin
*
* @param {Object} Vue
* @param {Object} opts
*/
module.exports = function (Vue, opts) {
opts = opts || {}
var lang = opts.lang || 'en'
var locales = opts.locales || opts.resources || {}
Vue.t = function (key) {
var ret = key || ''
var locale = locales[lang]
if (key && locale) {
var namespaces = key.split('.')
for (var i = 0; i < namespaces.length; i++) {
locale = locale[namespaces[i]]
if (!locale) {
ret = key
break
} else {
ret = locale
}
}
}
return ret
}
Vue.directive('t', {
isLiteral: true,
bind: function () {
if (this.el.nodeType !== 1) { return }
this.el.textContent = Vue.t(this.expression)
}
})
}
/***/ }
/******/ ])
});
if (typeof exports == "object") {
module.exports = require("vue-i18n");
} else if (typeof define == "function" && define.amd) {
define([], function(){ return require("vue-i18n"); });
} else {
this["vue-i18n"] = require("vue-i18n");
}
})()

@@ -15,4 +15,4 @@ {

"vue": "~0.10.6",
"vue-i18n": "~0.2.0"
"vue-i18n": "~1.0.0"
}
}

@@ -13,5 +13,5 @@ {

"dependencies": {
"vue": "^0.11.0-rc",
"vue-i18n": "^0.2.0"
"vue": "^0.11.4",
"vue-i18n": "^1.0.0"
}
}

@@ -0,1 +1,5 @@

# v1.0.0 / 2015-01-10
* Add `$t` method
# v0.11.0 / 2014-11-07

@@ -2,0 +6,0 @@

@@ -13,2 +13,12 @@ /**

// for Vue 0.11.4 later
try {
var path = Vue.parsers.path
Vue.prototype.$t = function (key) {
return key ? (path.get(locales[lang], key) || key) : ''
}
} catch (e) {
Vue.utils.warn('not support $t in this Vue version')
}
Vue.t = function (key) {

@@ -15,0 +25,0 @@ var ret = key || ''

{
"name": "vue-i18n",
"version": "0.11.0",
"version": "1.0.0",
"description": "Internationalization plugin of Vue.js",
"main": "lib/index.js",
"main": "index.js",
"scripts": {
"test": "make test_coveralls"
"test": "make ci"
},

@@ -26,10 +26,20 @@ "repository": {

"devDependencies": {
"component": "^1.0.0-rc5",
"coveralls": "^2.10.0",
"expect.js": "^0.3.1",
"jshint": "^2.5.0",
"mocha": "^1.18.2",
"mocha-phantomjs": "^3.3.2",
"poncho": "^0.1.1"
"vue": "~0.11.2",
"webpack": "^1.4.13",
"karma": "^0.12.24",
"karma-chrome-launcher": "^0.1.5",
"karma-commonjs": "0.0.12",
"karma-coverage": "^0.2.6",
"karma-coveralls": "^0.1.4",
"karma-expect": "^1.1.0",
"karma-firefox-launcher": "^0.1.3",
"karma-mocha": "^0.1.9",
"karma-phantomjs-launcher": "^0.1.4",
"karma-safari-launcher": "^0.1.1",
"karma-sauce-launcher": "^0.2.10",
"nightmare": "^1.6.5"
}
}

@@ -7,3 +7,5 @@ # vue-i18n

[![Dependency Status](https://david-dm.org/kazupon/vue-i18n.svg)](https://david-dm.org/kazupon/vue-i18n)
[![Sauce Test Status](https://saucelabs.com/buildstatus/vue-i18n)](https://saucelabs.com/u/vue-i18n)
Internationalization plugin of Vue.js

@@ -116,3 +118,45 @@

## $t method (for 0.11.4 later)
```html
<div id="message">
Message:<br>{{$t('message.hello')}}
</div>
```
```js
var Vue = require('vue')
var i18n = require('vue-i18n')
// ready translated locales
var locales = {
en: {
message: {
hello: 'the world'
}
},
ja: {
message: {
hello: 'ザ・ワールド'
}
}
}
// set plugin
Vue.use(i18n, {
lang: 'en',
locales: locales
})
new Vue().$mount('#message')
```
render the following:
```html
<div id="message">
Message:<br>the world
</div>
```
# Testing

@@ -126,4 +170,3 @@

# TODO
- specify default translate value
- fallback translate
See the `TODO.md`

@@ -133,2 +176,4 @@

## MIT
See the `LICENSE`.
/**
* import(s)
* Import(s)
*/
var i18n = require('vue-i18n')
var Vue = require('vue')
var Vue = require('../../node_modules/vue/dist/vue')
var i18n = require('../../index')

@@ -26,2 +26,59 @@

describe('$t', function () {
describe('en', function () {
it('should translate an english', function () {
Vue.use(i18n, {
lang: 'en',
locales: locales
})
var vm = new Vue()
expect(vm.$t('message.hello')).to.be.eql(locales.en.message.hello)
})
})
describe('ja', function () {
it('should translate a japanese', function () {
Vue.use(i18n, {
lang: 'ja',
resources: locales
})
var vm = new Vue()
expect(vm.$t('message.hello')).to.be.eql(locales.ja.message.hello)
})
})
describe('key', function () {
before(function () {
Vue.use(i18n, {
lang: 'en',
locales: locales
})
})
describe('not specify', function () {
it('should return empty string', function () {
var vm = new Vue()
expect(vm.$t()).to.be.eql('')
})
})
describe('empty string', function () {
it('should return empty string', function () {
var vm = new Vue()
expect(vm.$t('')).to.be.eql('')
})
})
describe('not found', function () {
it('should return key string', function () {
var vm = new Vue()
expect(vm.$t('foo.bar')).to.be.eql('foo.bar')
})
})
})
})
describe('Vue.t', function () {

@@ -53,7 +110,13 @@ describe('en', function () {

describe('v-t', function () {
before(function () {
Vue.config.async = false
})
after(function () {
Vue.config.async = true
})
describe('basic', function () {
describe('en', function () {
it('should translate an english', function () {
mock('translate-en', '<p v-t="message.hello"></p>')
Vue.use(i18n, {

@@ -63,7 +126,16 @@ lang: 'en',

})
var ViewModel = Vue.extend({
template: '<p v-t="message.hello"></p>',
el: function () {
var el = document.createElement('div')
el.id = 'translate-en'
document.body.appendChild(el)
return el
}
})
new ViewModel()
new Vue({ el: '#translate-en' })
var el = document.querySelector('#translate-en')
expect(el.textContent).to.be.eql(locales.en.message.hello)
expect(document.querySelector('#translate-en p').textContent)
.to.be.eql(locales.en.message.hello)
})

@@ -74,4 +146,2 @@ })

it('should translate a japanese', function () {
mock('translate-ja', '<p v-t="message.hello"></p>')
Vue.use(i18n, {

@@ -82,6 +152,15 @@ lang: 'ja',

new Vue({ el: '#translate-ja' })
var ViewModel = Vue.extend({
template: '<p v-t="message.hello"></p>',
el: function () {
var el = document.createElement('div')
el.id = 'translate-ja'
document.body.appendChild(el)
return el
}
})
new ViewModel()
var el = document.querySelector('#translate-ja')
expect(el.textContent).to.be.eql(locales.ja.message.hello)
expect(document.querySelector('#translate-ja p').textContent)
.to.be.eql(locales.ja.message.hello)
})

@@ -93,4 +172,2 @@ })

it('should not translate', function () {
mock('translate-it', '<p v-t="message.hello"></p>')
Vue.use(i18n, {

@@ -101,6 +178,15 @@ lang: 'it',

new Vue({ el: '#translate-it' })
var ViewModel = Vue.extend({
template: '<p v-t="message.hello"></p>',
el: function () {
var el = document.createElement('div')
el.id = 'translate-it'
document.body.appendChild(el)
return el
}
})
new ViewModel()
var el = document.querySelector('#translate-it')
expect(el.textContent).to.be.eql('message.hello')
expect(document.querySelector('#translate-it p').textContent)
.to.be.eql('message.hello')
})

@@ -111,4 +197,2 @@ })

it('should not translate', function () {
mock('translate-en-key-nothing', '<p v-t="message.foo"></p>')
Vue.use(i18n, {

@@ -119,6 +203,15 @@ lang: 'en',

new Vue({ el: '#translate-en-key-nothing' })
var ViewModel = Vue.extend({
template: '<p v-t="message.foo"></p>',
el: function () {
var el = document.createElement('div')
el.id = 'translate-en-key-nothing'
document.body.appendChild(el)
return el
}
})
new ViewModel()
var el = document.querySelector('#translate-en-key-nothing')
expect(el.textContent).to.be.eql('message.foo')
expect(document.querySelector('#translate-en-key-nothing p').textContent)
.to.be.eql('message.foo')
})

@@ -129,4 +222,2 @@ })

it('should not translate', function () {
mock('translate-key-empty', '<p v-t=""></p>')
Vue.use(i18n, {

@@ -137,42 +228,20 @@ lang: 'en',

new Vue({ el: '#translate-key-empty' })
var el = document.querySelector('#translate-key-empty')
expect(el.textContent).to.be.eql('')
})
})
/*
describe('specify default value', function () {
it('should translate with default value', function () {
mock(
'translate-default-value',
'<p v-t="message.hello: {{hello}}"></p>'
)
Vue.use(i18n, {
lang: 'en',
locales: locales
})
new Vue({
el: '#translate-default-value',
data: {
hello: 'スタープラチナ ザ・ワールド'
var ViewModel = Vue.extend({
template: '<p v-t=""></p>',
el: function () {
var el = document.createElement('div')
el.id = 'translate-key-empty'
document.body.appendChild(el)
return el
}
})
new ViewModel()
var el = document.querySelector('#translate-default-value')
expect(el.textContent).to.be.eql('スタープラチナ ザ・ワールド')
expect(document.querySelector('#translate-key-empty p').
textContent).to.be.eql('')
})
})
*/
describe('translate component module', function () {
it('should translate', function () {
mock(
'translate-parent',
'<div><p v-t="message.hello"></p><div v-component="hoge"></div></div>'
)
Vue.use(i18n, {

@@ -183,4 +252,10 @@ lang: 'en',

new Vue({
el: '#translate-parent',
var ViewModel = Vue.extend({
template: '<div><p v-t="message.hello"></p><div v-component="hoge"></div></div>',
el: function () {
var el = document.createElement('div')
el.id = 'translate-parent'
document.body.appendChild(el)
return el
},
components: {

@@ -192,2 +267,3 @@ hoge: Vue.extend({

})
new ViewModel()

@@ -194,0 +270,0 @@ var child_el = document.querySelector('#translate-child')

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc