File tree Expand file tree Collapse file tree 10 files changed +138
-47
lines changed Expand file tree Collapse file tree 10 files changed +138
-47
lines changed Original file line number Diff line number Diff line change 1
- describe ( 'example' , ( ) => {
2
- beforeAll ( async ( ) => {
3
- await page . goto ( 'http://localhost:8080/' )
4
- } )
1
+ ; [ 'composable' , 'legacy' ] . forEach ( pattern => {
2
+ describe ( `${ pattern } ` , ( ) => {
3
+ beforeAll ( async ( ) => {
4
+ await page . goto ( `http://localhost:8080/${ pattern } /` )
5
+ } )
6
+
7
+ test ( 'initial rendering' , async ( ) => {
8
+ await expect ( page ) . toMatch ( '言語' )
9
+ await expect ( page ) . toMatch ( 'こんにちは、世界!' )
10
+ } )
5
11
6
- test ( 'rendering' , async ( ) => {
7
- await expect ( page ) . toMatch ( 'こんにちは、世界!' )
12
+ test ( 'change locale' , async ( ) => {
13
+ await page . select ( '#app select' , 'en' )
14
+ await expect ( page ) . toMatch ( 'Language' )
15
+ await expect ( page ) . toMatch ( 'hello, world!' )
16
+ } )
8
17
} )
9
18
} )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <form >
3
+ <label >{{ t('language') }}</label >
4
+ <select v-model =" locale" >
5
+ <option value =" en" >en</option >
6
+ <option value =" ja" >ja</option >
7
+ </select >
8
+ </form >
9
+ <p >{{ t('hello') }}</p >
10
+ </template >
11
+
12
+ <script >
13
+ import { useI18n } from ' vue-i18n'
14
+
15
+ export default {
16
+ name: ' App' ,
17
+ setup () {
18
+ return useI18n ({
19
+ locale: ' ja'
20
+ })
21
+ }
22
+ }
23
+ </script >
24
+
25
+ <i18n >
26
+ {
27
+ "en": {
28
+ "language": "Language",
29
+ "hello": "hello, world!"
30
+ },
31
+ "ja": {
32
+ "language": "言語",
33
+ "hello": "こんにちは、世界!"
34
+ }
35
+ }
36
+ </i18n >
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < meta charset ="utf-8 " />
5
+ < title > vue-i18n-loader example</ title >
6
+ </ head >
7
+ < body >
8
+ < div id ="app ">
9
+ < App />
10
+ </ div >
11
+ < script src ="/dist/composable.js "> </ script >
12
+ </ body >
13
+ </ html >
Original file line number Diff line number Diff line change
1
+ import { createApp } from 'vue'
2
+ import { createI18nComposer } from 'vue-i18n'
3
+ import App from './App.vue'
4
+
5
+ const i18n = createI18nComposer ( {
6
+ locale : 'ja' ,
7
+ messages : { }
8
+ } )
9
+
10
+ const app = createApp ( App )
11
+
12
+ app . use ( i18n )
13
+ app . mount ( '#app' )
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <form >
3
+ <label >{{ $t('language') }}</label >
4
+ <select v-model =" $i18n.locale" >
5
+ <option value =" en" >en</option >
6
+ <option value =" ja" >ja</option >
7
+ </select >
8
+ </form >
9
+ <p >{{ $t('hello') }}</p >
10
+ </template >
11
+
12
+ <script >
13
+ export default {
14
+ name: ' App'
15
+ }
16
+ </script >
17
+
18
+ <i18n >
19
+ {
20
+ "en": {
21
+ "language": "Language",
22
+ "hello": "hello, world!"
23
+ },
24
+ "ja": {
25
+ "language": "言語",
26
+ "hello": "こんにちは、世界!"
27
+ }
28
+ }
29
+ </i18n >
Original file line number Diff line number Diff line change 5
5
< title > vue-i18n-loader example</ title >
6
6
</ head >
7
7
< body >
8
- < div id ="app "> </ div >
9
- < script src ="/dist/bundle.js "> </ script >
8
+ < div id ="app ">
9
+ < App />
10
+ </ div >
11
+ < script src ="/dist/legacy.js "> </ script >
10
12
</ body >
11
13
</ html >
Original file line number Diff line number Diff line change
1
+ import { createApp } from 'vue'
2
+ import { createI18n } from 'vue-i18n'
3
+ import App from './App.vue'
4
+
5
+ const i18n = createI18n ( {
6
+ locale : 'ja' ,
7
+ messages : { }
8
+ } )
9
+
10
+ const app = createApp ( App )
11
+
12
+ app . use ( i18n )
13
+ app . mount ( '#app' )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
const path = require ( 'path' )
2
- const VueLoaderPlugin = require ( 'vue-loader/lib/plugin ' )
2
+ const { VueLoaderPlugin } = require ( 'vue-loader' )
3
3
4
4
module . exports = {
5
5
mode : 'development' ,
6
- entry : path . resolve ( __dirname , './main.js' ) ,
6
+ entry : {
7
+ composable : path . resolve ( __dirname , './composable/main.js' ) ,
8
+ legacy : path . resolve ( __dirname , './legacy/main.js' )
9
+ } ,
7
10
output : {
8
11
path : path . resolve ( __dirname , 'dist' ) ,
9
- filename : 'bundle .js' ,
12
+ filename : '[name] .js' ,
10
13
publicPath : '/dist/'
11
14
} ,
15
+ resolve : {
16
+ alias : {
17
+ // this isn't technically needed, since the default `vue` entry for bundlers
18
+ // is a simple `export * from '@vue/runtime-dom`. However having this
19
+ // extra re-export somehow causes webpack to always invalidate the module
20
+ // on the first HMR update and causes the page to reload.
21
+ 'vue' : '@vue/runtime-dom'
22
+ }
23
+ } ,
12
24
devServer : {
13
25
stats : 'minimal' ,
14
26
contentBase : __dirname
You can’t perform that action at this time.
0 commit comments