https://github.com/instance-oom/i18n-locales
https://github.com/instance-oom/i18n-locales
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/instance-oom/i18n-locales
- Owner: instance-oom
- Created: 2024-05-22T09:07:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-22T09:11:15.000Z (over 1 year ago)
- Last Synced: 2024-05-22T10:34:32.027Z (over 1 year ago)
- Language: TypeScript
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## 💿 Installation
```sh
npm i @instance-oom/i18n-locales
```
```ts
// vite.config.ts
import VueI18nLocalesPlugin from '@instance-oom/i18n-locales/vite';
export default defineConfig({
plugins: [
VueI18nLocalesPlugin({ dir: path.resolve(__dirname, './src/locales') }),
vue()
],
})
```
```ts
// xxx.ts
import { createApp } from 'vue'
import { createI18n } from 'vue-i18n'
/*
* All i18n resources specified in the plugin `include` option can be loaded
* at once using the import syntax
*/
import messages from '@instance-oom/i18n-locales/messages';
import { createI18nLocales } from '@instance-oom/i18n-locales/locales';
const i18n = createI18n({
locale: 'en',
messages: messages
})
const app = createApp()
app
.use(createI18nLocales())
.use(i18n)
.mount('#app');
```
```vue
{{ $t(LOCALES.xxx) }}
```