{"id":13424098,"url":"https://github.com/Haixing-Hu/vue-i18n","last_synced_at":"2025-03-15T18:33:54.997Z","repository":{"id":57396225,"uuid":"43441499","full_name":"Haixing-Hu/vue-i18n","owner":"Haixing-Hu","description":"Internationalization plugin of Vue.js","archived":false,"fork":false,"pushed_at":"2016-08-08T15:19:26.000Z","size":277,"stargazers_count":62,"open_issues_count":5,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-17T04:22:16.301Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Haixing-Hu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-30T15:36:37.000Z","updated_at":"2021-10-09T12:28:59.000Z","dependencies_parsed_at":"2022-09-18T12:10:37.313Z","dependency_job_id":null,"html_url":"https://github.com/Haixing-Hu/vue-i18n","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haixing-Hu%2Fvue-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haixing-Hu%2Fvue-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haixing-Hu%2Fvue-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haixing-Hu%2Fvue-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Haixing-Hu","download_url":"https://codeload.github.com/Haixing-Hu/vue-i18n/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221601257,"owners_count":16850310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T00:00:48.581Z","updated_at":"2024-10-26T23:30:15.214Z","avatar_url":"https://github.com/Haixing-Hu.png","language":"JavaScript","funding_links":[],"categories":["Awesome Vue.js [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)","Awesome Vue.js"],"sub_categories":["Libraries \u0026 Plugins"],"readme":"# vue-i18n\r\n\r\n[![Build Status](https://circleci.com/gh/Haixing-Hu/vue-i18n/tree/master.svg?style=shield)](https://circleci.com/gh/Haixing-Hu/vue-i18n/tree/master)\r\n[![Coverage Status](https://coveralls.io/repos/Haixing-Hu/vue-i18n/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/Haixing-Hu/vue-i18n?branch=master)\r\n[![bitHound Score](https://www.bithound.io/github/Haixing-Hu/vue-i18n/badges/score.svg)](https://www.bithound.io/github/Haixing-Hu/vue-i18n)\r\n[![Dependency Status](https://david-dm.org/Haixing-Hu/vue-i18n.svg)](https://david-dm.org/Haixing-Hu/vue-i18n)\r\n[![devDependency Status](https://david-dm.org/Haixing-Hu/vue-i18n/dev-status.svg)](https://david-dm.org/Haixing-Hu/vue-i18n#info=devDependencies)\r\n\r\nYet another internationalization plugin for Vue.js.\r\n\r\n# Requirements\r\n- [Vue.js](https://github.com/yyx990803/vue) `^1.0.24`\r\n- [JQuery](https://github.com/jquery/jquery) `^2.2.4`\r\n\r\n# Instllation\r\n\r\n## npm\r\n\r\n```shell\r\n$ npm install vue-i18n-plugin\r\n```\r\n\r\n## bower\r\n\r\n```shell\r\n$ bower install vue-i18n-plugin\r\n```\r\n\r\n# Usage\r\n\r\nJSON file: `resources/i18n/en-US.json`\r\n\r\n```json\r\n{\r\n  \"message\": {\r\n    \"hello\": \"Hello\",\r\n    \"world\": \"World\"\r\n  }\r\n}\r\n```\r\n\r\nJSON file: `resources/i18n/zh-CN.json`\r\n```json\r\n{\r\n  \"message\": {\r\n    \"hello\": \"您好\",\r\n    \"world\": \"世界\"\r\n  }\r\n}\r\n```\r\n\r\n```javascript\r\nvar Vue = require('vue');\r\nvar i18n = require('vue-i18n');\r\n\r\n// set plugin\r\nVue.use(i18n, {\r\n  baseUrl: 'resources/i18n'\r\n});\r\n\r\n// create instance\r\nnew Vue({\r\n  el: '#test-i18n',\r\n  beforeCompile: function() {\r\n    this.$setLanguage(\"zh-CN\");\r\n  },\r\n  methods: {\r\n    switchLanguage: function(lang) {\r\n      this.$setLanguage(lang);\r\n    }\r\n  }\r\n});\r\n```\r\n\r\nTemplate the following:\r\n\r\n```html\r\n\u003cdiv id=\"test-i18n\" class=\"message\"\u003e\r\n  \u003cp\u003eLanguage: {{$language}}\u003c/p\u003e\r\n  \u003cp\u003e{{$i18n.message.hello}}, {{$i18n.message.world}}\u003c/p\u003e\r\n\u003c/div\u003e\r\n```\r\n\r\nOutput the following:\r\n\r\n```html\r\n\u003cdiv id=\"test-i18n\" class=\"message\"\u003e\r\n  \u003cp\u003eLanguage: zh-CN\u003c/p\u003e\r\n  \u003cp\u003e您好, 世界\u003c/p\u003e\r\n\u003c/div\u003e\r\n```\r\n# Formatting Messages\r\n\r\nThis plugin could work together with the [vue-format](https://github.com/Haixing-Hu/vue-format/) plugin.\r\n\r\nJSON file: `resources/i18n/en.json`\r\n\r\n```json\r\n{\r\n  \"message\": {\r\n    \"hello\": \"Hello {0}, {1}!\"\r\n  }\r\n}\r\n```\r\n\r\nTemplate the following:\r\n\r\n```html\r\n\u003cdiv class=\"message\"\u003e\r\n  \u003cp\u003e{{ $i18n.message.hello | format \"world\" 123 }}\u003c/p\u003e\r\n\u003c/div\u003e\r\n```\r\n\r\nOutput the following:\r\n\r\n```html\r\n\u003cdiv class=\"message\"\u003e\r\n  \u003cp\u003eHello world, 123!\u003c/p\u003e\r\n\u003c/div\u003e\r\n```\r\n\r\n# API\r\n\r\n## `$setLanguage(lang)`\r\n\r\nSets the current language. Calling this value will reload the localization files\r\naccording to the new language and change the current displayed language.\r\n\r\n- `lang`: the code of the new language.\r\n\r\n## `$language`\r\n\r\nStores the current language.\r\n\r\n## `$i18n`\r\n\r\nAn object which contains the localization messages for the current language.\r\n\r\n# Options\r\n\r\n## Plugin options\r\n\r\n```javascript\r\nVue.use(plugin, {\r\n  baseUrl: \"i18n\"\r\n  fallbackLanguage: \"en-US\",\r\n  timeout: 500,\r\n  async: false\r\n})\r\n```\r\n\r\n### `baseUrl`\r\nSpecify the base URL of the localization files, which could be either an\r\nabsolute URL, or a relative URL relative to the current javascript file.\r\n\r\nThe default value of this option is `i18n`.\r\n\r\n### `fallbackLanguage`\r\n\r\nSpecify the code of the fallback langauge. If the localization file of the\r\ncurrent language cannot be load, the localization file of the fallback language\r\nwill be load.\r\n\r\nThe default value of this option is `en-US`.\r\n\r\n### `timeout`\r\n\r\nThe timeout for the AJAX calls, in milliseconds. Default value is `500`.\r\n\r\n### `async`\r\n\r\nIndicates whether to load the localization file asynchronously. Default value\r\nis `false`.\r\n\r\n# Contributing\r\n- Fork it !\r\n- Create your top branch from `dev`: `git branch my-new-topic origin/dev`\r\n- Commit your changes: `git commit -am 'Add some topic'`\r\n- Push to the branch: `git push origin my-new-topic`\r\n- Submit a pull request to `dev` branch of `Haixing-Hu/vue-i18n` repository !\r\n\r\n# Building and Testing\r\n\r\nFirst you should install all depended NPM packages. The NPM packages are used\r\nfor building and testing this package.\r\n\r\n```shell\r\n$ npm install\r\n```\r\n\r\nThen install all depended bower packages. The bower packages are depended by\r\nthis packages.\r\n\r\n```shell\r\n$ bower install\r\n```\r\n\r\nNow you can build the project.\r\n```shell\r\n$ gulp build\r\n```\r\n\r\nThe following command will test the project.\r\n```shell\r\n$ gulp test\r\n```\r\n\r\nThe following command will perform the test and generate a coverage report.\r\n```shell\r\n$ gulp test:coverage\r\n```\r\n\r\nThe following command will perform the test, generate a coverage report, and\r\nupload the coverage report to [coveralls.io](https://coveralls.io/).\r\n```shell\r\n$ gulp test:coveralls\r\n```\r\n\r\nYou can also run `bower install` and `gulp build` together with the following\r\ncommand:\r\n```shell\r\nnpm run build\r\n```\r\n\r\nOr run `bower install` and `gulp test:coveralls` together with the following\r\ncommand:\r\n```shell\r\nnpm run test\r\n```\r\n\r\n# License\r\n\r\n## MIT\r\n\r\n[MIT](http://opensource.org/licenses/MIT)\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHaixing-Hu%2Fvue-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHaixing-Hu%2Fvue-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHaixing-Hu%2Fvue-i18n/lists"}