@visionm/vue-i18n-composable
v0.2.2
Published
Composition API for vue-i18n in Vue 2.x
Downloads
1
Maintainers
Readme
vue-i18n-composable
Composition API for vue-i18n
in Vue 2.x
Install
Usage
// main.js
import Vue from 'vue'
import VueCompositionAPI, { createApp } from '@vue/composition-api'
import { createI18n } from 'vue-i18n-composable'
import App from './App.vue'
Vue.use(VueCompositionAPI)
const i18n = createI18n({
locale: 'ja',
messages: {
en: {
language: 'English',
},
ja: {
language: '日本語',
},
},
})
const app = createApp({
render: h => h(App),
i18n,
})
app.mount('#app')
In components
<template>
<div>{{ t('language') }}</div>
</template>
<script>
import { defineComponent } from '@vue/composition-api'
import { useI18n } from 'vue-i18n-composable'
export default defineComponent({
setup() {
return {
...useI18n()
}
}
})
</script>
📄 License
MIT License © 2020 Anthony Fu