@yfwz100/vite-plugin-vue2-i18n

The missing vue 2 SFC version of vite plugin for vue-i18n, inspired by the rollup one.
147,915 6
Install
npm install @yfwz100/vite-plugin-vue2-i18n@1.0.0
Latest Version:1.0.0
License:MIT
Last Updated:Dec 17, 2022
Links: GitHub  ·  npm
Maintainer: yfwz100

@yfwz100/vite-plugin-vue2-i18n

The missing vue 2 SFC version of vite plugin for vue-i18n, inspired by the rollup one.

Requirement

You need to install the follwoing:

Installation

npm:

$ npm i --save-dev @rollup/plugin-json
$ npm i --save-dev @rollup/plugin-yaml # if you use locale messages with YAML format
$ npm i --save-dev @yfwz100/vite-plugin-vue2-i18n

Usages

Say we have configured the vite via vite.config.js and have a sample index.html (see the vite guide):

import { defineConfig } from 'vite';
import { createVuePlugin } from '@yfwz100/vite-plugin-vue2';
import { createI18nPlugin } from '@yfwz100/vite-plugin-vue2-i18n';

export default defineConfig({
  plugins: [createVuePlugin(), createI18nPlugin()],
});

Then, we can write the i18n blocks in the vue component file:

<template>
  <p>{{ $t('hello') }}</p>
</template>

<i18n>
{
  "en": {
    "hello": "Hello World!"
  },
  "zh": {
    "hello": "你好,世界!"
  }
}
</i18n>

Finally, just run vite and see the component with i18n enabled.

Locale Messages Format

We have tested the following formats:

See more in the playground folder.

Changelog

See CHANGELOG.md.

Related Packages

vite-plugin-vue2

Vite plugin for Vue2

1,474,659 618
vite-plugin-git-revision

Vite plugin that generates VERSION and COMMITHASH files during build based on a...

21,961 11
@koala/yibin-ui

宜宾大脑主题定制

4,077
vite-plugin-vue2-plus

Vite plugin for Vue2

854 618
vitepress-v2

VitePress for vue2

843 1

Version History

Version Released License
1.0.0 MIT
Pre-releases (5)
Version Released License
1.0.0-6 MIT
1.0.0-4 MIT
1.0.0-3 MIT
1.0.0-2 MIT
1.0.0-1 MIT