0.3.0 • Published 1 year ago

@rokoli/vue-tiny-i18n v0.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

vue-tiny-1i8n

A very tiny Vue3 i18n library.

Install

npm install --save @rokoli/vue-tiny-i18n

Configuration with Vite

// vite.config.js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import TinyI18nPlugin from '@rokoli/vue-tiny-i18n/plugin'

export default defineConfig({
  plugins: [vue(), TinyI18nPlugin()],
})

Usage

Create the i18n plugin along with Vue’s createApp:

// main.js
import { createApp } from 'vue'
import { createI18n } from '@rokoli/vue-tiny-i18n'
import App from './App.vue'

createApp(App)
  .use(createI18n({ locale: 'de' }))
  .mount('#app')

Then use it in your components like this:

<template>
  <h1>{{ t('title') }}</h1>
</template>

<script setup>
import { useI18n } from '@rokoli/vue-tiny-i18n'
const { t } = useI18n()
</script>

<i18n lang="yaml">
en:
  title: Hello World!
de:
  title: Hallo Welt!
</i18n>
0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago