vue-i18n-composable
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.2 • Public • Published

    vue-i18n-composable

    Composition API for vue-i18n in Vue 2.x

    npm

    Install

    npm i vue-i18n vue-i18n-composable @vue/composition-api
    

    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

    Keywords

    none

    Install

    npm i vue-i18n-composable

    DownloadsWeekly Downloads

    547

    Version

    0.2.2

    License

    MIT

    Unpacked Size

    7.05 kB

    Total Files

    7

    Last publish

    Collaborators

    • kazupon
    • antfu