-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support v12: revert rollup-plugin, vite-plugin and loader
- Loading branch information
Showing
45 changed files
with
609 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<template> | ||
<form> | ||
<label>{{ $t('language') }}</label> | ||
<select v-model="$i18n.locale"> | ||
<option value="en">en</option> | ||
<option value="ja">ja</option> | ||
</select> | ||
</form> | ||
<p>{{ $t('hello') }}</p> | ||
<Banana /> | ||
</template> | ||
|
||
<script> | ||
import Banana from './Banana.vue' | ||
export default { | ||
name: 'App', | ||
components: { | ||
Banana | ||
} | ||
} | ||
</script> | ||
|
||
<i18n> | ||
{ | ||
"en": { | ||
"language": "Language", | ||
"hello": "hello, world!" | ||
}, | ||
"ja": { | ||
"language": "言語", | ||
"hello": "こんにちは、世界!" | ||
} | ||
} | ||
</i18n> |
19 changes: 19 additions & 0 deletions
19
packages/rollup-plugin-vue-i18n/examples/legacy/Banana.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<template> | ||
<form id="fruits"> | ||
<label>{{ $t('select') }}</label> | ||
<select v-model.number="select"> | ||
<option value="0">0</option> | ||
<option value="1">1</option> | ||
<option value="2">2</option> | ||
<option value="3">3</option> | ||
</select> | ||
</form> | ||
<p>{{ $tc('fruits.banana', select, { n: select }) }}</p> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'Banana', | ||
data: () => ({ select: 0 }) | ||
} | ||
</script> |
13 changes: 13 additions & 0 deletions
13
packages/rollup-plugin-vue-i18n/examples/legacy/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>rollup-plugin-vue-i18n composable example</title> | ||
</head> | ||
<body> | ||
<div id="app"> | ||
<App /> | ||
</div> | ||
<script src="./index.js"></script> | ||
</body> | ||
</html> |
3 changes: 3 additions & 0 deletions
3
packages/rollup-plugin-vue-i18n/examples/legacy/locales/en.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
select: Do you want banana? | ||
fruits: | ||
banana: 'no bananas | {n} banana | {n} bananas' |
6 changes: 6 additions & 0 deletions
6
packages/rollup-plugin-vue-i18n/examples/legacy/locales/ja.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"select": "バナナが欲しい?", | ||
"fruits": { | ||
"banana": "バナナがない | バナナ {n} 個" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createApp } from 'vue' | ||
import { createI18n } from 'vue-i18n' | ||
import App from './App.vue' | ||
|
||
import ja from './locales/ja.json' | ||
import en from './locales/en.yaml' | ||
|
||
const i18n = createI18n({ | ||
legacy: true, | ||
locale: 'ja', | ||
messages: { | ||
en, | ||
ja | ||
} | ||
}) | ||
|
||
const app = createApp(App) | ||
|
||
app.use(i18n) | ||
app.mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
describe('legacy', () => { | ||
beforeAll(async () => { | ||
await page.goto(`http://localhost:8080/legacy/`) | ||
}) | ||
|
||
test('initial rendering', async () => { | ||
await expect(page).toMatch('言語') | ||
await expect(page).toMatch('こんにちは、世界!') | ||
await expect(page).toMatch('バナナが欲しい?') | ||
await expect(page).toMatch('バナナ 0 個') | ||
}) | ||
|
||
test('change locale', async () => { | ||
await page.select('#app select', 'en') | ||
await expect(page).toMatch('Language') | ||
await expect(page).toMatch('hello, world!') | ||
await expect(page).toMatch('no bananas') | ||
}) | ||
|
||
test('change banana select', async () => { | ||
await page.select('#fruits select', '3') | ||
await expect(page).toMatch('3 bananas') | ||
await page.select('#app select', 'ja') | ||
await expect(page).toMatch('バナナ 3 個') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<template> | ||
<form> | ||
<label>{{ $t('language') }}</label> | ||
<select v-model="$i18n.locale"> | ||
<option value="en">en</option> | ||
<option value="ja">ja</option> | ||
</select> | ||
</form> | ||
<p>{{ $t('hello') }}</p> | ||
<Banana /> | ||
</template> | ||
|
||
<script> | ||
import Banana from './Banana.vue' | ||
export default { | ||
name: 'App', | ||
components: { | ||
Banana | ||
} | ||
} | ||
</script> | ||
|
||
<i18n> | ||
{ | ||
"en": { | ||
"language": "Language", | ||
"hello": "hello, world!" | ||
}, | ||
"ja": { | ||
"language": "言語", | ||
"hello": "こんにちは、世界!" | ||
} | ||
} | ||
</i18n> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<template> | ||
<form id="fruits"> | ||
<label>{{ $t('select') }}</label> | ||
<select v-model.number="select"> | ||
<option value="0">0</option> | ||
<option value="1">1</option> | ||
<option value="2">2</option> | ||
<option value="3">3</option> | ||
</select> | ||
</form> | ||
<p>{{ $tc('fruits.banana', select, { n: select }) }}</p> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'Banana', | ||
data: () => ({ select: 0 }) | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>vite-plugin-vue-i18n legacy example</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="./main.ts"></script> | ||
</body> | ||
</html> |
3 changes: 3 additions & 0 deletions
3
packages/vite-plugin-vue-i18n/examples/legacy/locales/en.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
select: Do you want banana? | ||
fruits: | ||
banana: 'no bananas | {n} banana | {n} bananas' |
6 changes: 6 additions & 0 deletions
6
packages/vite-plugin-vue-i18n/examples/legacy/locales/ja.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"select": "バナナが欲しい?", | ||
"fruits": { | ||
"banana": "バナナがない | バナナ {n} 個" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { createApp } from 'vue' | ||
import { createI18n } from 'vue-i18n' | ||
import App from './App.vue' | ||
import en from './locales/en.yaml' | ||
import ja from './locales/ja.json' | ||
|
||
const i18n = createI18n({ | ||
legacy: true, | ||
locale: 'ja', | ||
messages: { | ||
en, | ||
ja | ||
} | ||
}) | ||
|
||
const app = createApp(App) | ||
|
||
app.use(i18n) | ||
app.mount('#app') |
14 changes: 14 additions & 0 deletions
14
packages/vite-plugin-vue-i18n/examples/legacy/vite.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import path from 'path' | ||
import { defineConfig } from 'vite' | ||
import vue from '@vitejs/plugin-vue' | ||
import vueI18n from '../../src/index' | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
vue(), | ||
vueI18n({ | ||
include: path.resolve(__dirname, './locales/**'), | ||
compositionOnly: false | ||
}) | ||
] | ||
}) |
Oops, something went wrong.