@rokoli/vue-tiny-i18n
A very tiny Vue3 i18n library.
4,569
| Install | |
|---|---|
npm install @rokoli/vue-tiny-i18n |
|
| Latest Version: | 0.3.0 |
| Vue: | 3 |
| License: | MIT |
| Last Updated: | Apr 27, 2023 |
| Links: | Repository · npm |
Maintainer: kmohrf
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>
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 0.3.0 | ^3.2 | MIT | |
| 0.2.0 | ^3.2 | MIT | |
| 0.1.0 | ^3.2 | MIT |