npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

vue-i18n-plugin

v0.2.2

Published

A Vue.js plugin provides the internationalization function.

Downloads

180

Readme

vue-i18n

Build Status Coverage Status bitHound Score Dependency Status devDependency Status

Yet another internationalization plugin for Vue.js.

Requirements

Instllation

npm

$ npm install vue-i18n-plugin

bower

$ bower install vue-i18n-plugin

Usage

JSON file: resources/i18n/en-US.json

{
  "message": {
    "hello": "Hello",
    "world": "World"
  }
}

JSON file: resources/i18n/zh-CN.json

{
  "message": {
    "hello": "您好",
    "world": "世界"
  }
}
var Vue = require('vue');
var i18n = require('vue-i18n');

// set plugin
Vue.use(i18n, {
  baseUrl: 'resources/i18n'
});

// create instance
new Vue({
  el: '#test-i18n',
  beforeCompile: function() {
    this.$setLanguage("zh-CN");
  },
  methods: {
    switchLanguage: function(lang) {
      this.$setLanguage(lang);
    }
  }
});

Template the following:

<div id="test-i18n" class="message">
  <p>Language: {{$language}}</p>
  <p>{{$i18n.message.hello}}, {{$i18n.message.world}}</p>
</div>

Output the following:

<div id="test-i18n" class="message">
  <p>Language: zh-CN</p>
  <p>您好, 世界</p>
</div>

Formatting Messages

This plugin could work together with the vue-format plugin.

JSON file: resources/i18n/en.json

{
  "message": {
    "hello": "Hello {0}, {1}!"
  }
}

Template the following:

<div class="message">
  <p>{{ $i18n.message.hello | format "world" 123 }}</p>
</div>

Output the following:

<div class="message">
  <p>Hello world, 123!</p>
</div>

API

$setLanguage(lang)

Sets the current language. Calling this value will reload the localization files according to the new language and change the current displayed language.

  • lang: the code of the new language.

$language

Stores the current language.

$i18n

An object which contains the localization messages for the current language.

Options

Plugin options

Vue.use(plugin, {
  baseUrl: "i18n"
  fallbackLanguage: "en-US",
  timeout: 500,
  async: false
})

baseUrl

Specify the base URL of the localization files, which could be either an absolute URL, or a relative URL relative to the current javascript file.

The default value of this option is i18n.

fallbackLanguage

Specify the code of the fallback langauge. If the localization file of the current language cannot be load, the localization file of the fallback language will be load.

The default value of this option is en-US.

timeout

The timeout for the AJAX calls, in milliseconds. Default value is 500.

async

Indicates whether to load the localization file asynchronously. Default value is false.

Contributing

  • Fork it !
  • Create your top branch from dev: git branch my-new-topic origin/dev
  • Commit your changes: git commit -am 'Add some topic'
  • Push to the branch: git push origin my-new-topic
  • Submit a pull request to dev branch of Haixing-Hu/vue-i18n repository !

Building and Testing

First you should install all depended NPM packages. The NPM packages are used for building and testing this package.

$ npm install

Then install all depended bower packages. The bower packages are depended by this packages.

$ bower install

Now you can build the project.

$ gulp build

The following command will test the project.

$ gulp test

The following command will perform the test and generate a coverage report.

$ gulp test:coverage

The following command will perform the test, generate a coverage report, and upload the coverage report to coveralls.io.

$ gulp test:coveralls

You can also run bower install and gulp build together with the following command:

npm build

Or run bower install and gulp test:coveralls together with the following command:

npm test

License

MIT

MIT