Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/h3poteto/vue3-i18next
Internationalization for Vue3. Using the i18next i18n ecosystem.
https://github.com/h3poteto/vue3-i18next
Last synced: about 1 month ago
JSON representation
Internationalization for Vue3. Using the i18next i18n ecosystem.
- Host: GitHub
- URL: https://github.com/h3poteto/vue3-i18next
- Owner: h3poteto
- License: mit
- Created: 2022-04-21T13:03:18.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-03-31T17:19:33.000Z (over 1 year ago)
- Last Synced: 2024-09-30T20:08:16.709Z (about 1 month ago)
- Language: TypeScript
- Homepage:
- Size: 239 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# vue3-i18next
[![Build](https://github.com/h3poteto/vue3-i18next/actions/workflows/build.yml/badge.svg)](https://github.com/h3poteto/vue3-i18next/actions/workflows/build.yml)
[![NPM Version](https://img.shields.io/npm/v/vue3-i18next.svg)](https://www.npmjs.com/package/vue3-i18next)
[![GitHub release](https://img.shields.io/github/release/h3poteto/vue3-i18next.svg)](https://github.com/h3poteto/vue3-i18next/releases)
[![npm](https://img.shields.io/npm/dm/vue3-i18next)](https://www.npmjs.com/package/vue3-i18next)
[![NPM](https://img.shields.io/npm/l/vue3-i18next)](/LICENSE.txt)This is the repository for Vue i18next for Vue3. If you use i18next for Vue2, see this [repository](https://github.com/panter/vue-i18next).
## Install
```
$ npm install -S vue3-i18next
```or
```
$ yarn add vue3-i18next
```### Requirements
- vue >= 3.2.0
- i18next >= 21.0.0## Usage
### Init```typescript
import { createApp } from "vue";
import { createI18n } from "vue3-i18next";
import i18next, { InitOptions } from "i18next";import App from "./App.vue";
const locales = {
en: {
message: {
hello: 'Hello!',
loadbundle: 'Load bundle language: {{lang}}',
},
},
};const options: InitOptions = {
initImmediate: false,
lng: "en",
fallbackLng: "en",
saveMissing: true,
resources: {
en: {
translation: locales.en,
},
},
};
i18next.init(options);
const i18n = createI18n(i18next);const app = createApp(App);
app.use(i18n);
app.mount("#app");
```### Component based localization
```vue
{{ $t('message.hello') }}
{{ loadbundle() }}
import { defineComponent } from "vue";
import { useI18next } from "vue3-i18next";export default defineComponent({
name: 'App',
setup() {
const i18n = useI18next();
const loadbundle = () => i18n.t('message.loadbundle', {lang: 'en'});return {
loadbundle,
};
},
});```
## License
The software is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).