Skip to content

Commit ad53bc1

Browse files
committed
Merge branch 'master' of github.com:intlify/vue-i18n-next
2 parents 471bc6e + 924cbde commit ad53bc1

File tree

28 files changed

+903
-3101
lines changed

28 files changed

+903
-3101
lines changed

e2e/functions/linked.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
;['composition', 'legacy'].forEach(pattern => {
2+
describe(`${pattern}`, () => {
3+
beforeAll(async () => {
4+
await page.goto(
5+
`http://localhost:8080/examples/${pattern}/functions/linked.html`
6+
)
7+
})
8+
9+
test('initial rendering', async () => {
10+
await expect(page).toMatch('DIO: the world !!!!')
11+
await expect(page).toMatch('Please provide home address')
12+
await expect(page).toMatch('custom modifiers example: snake-case')
13+
})
14+
15+
test('change locale', async () => {
16+
await page.select('#app select', 'ja')
17+
await expect(page).toMatch('ディオ: ザ・ワールド !!!!')
18+
await expect(page).toMatch('どうか、ホームアドレス を提供してください。')
19+
await expect(page).toMatch('カスタム修飾子の例: スネーク-ケース')
20+
})
21+
})
22+
})

e2e/functions/list.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
;['composition', 'legacy'].forEach(pattern => {
2+
describe(`${pattern}`, () => {
3+
beforeAll(async () => {
4+
await page.goto(
5+
`http://localhost:8080/examples/${pattern}/functions/list.html`
6+
)
7+
})
8+
9+
test('initial rendering', async () => {
10+
await expect(page).toMatch('こんにちは、kazupon!')
11+
})
12+
13+
test('change locale', async () => {
14+
await page.select('#app select', 'en')
15+
await expect(page).toMatch('Hello, kazupon!')
16+
})
17+
})
18+
})

e2e/functions/named.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
;['composition', 'legacy'].forEach(pattern => {
2+
describe(`${pattern}`, () => {
3+
beforeAll(async () => {
4+
await page.goto(
5+
`http://localhost:8080/examples/${pattern}/functions/named.html`
6+
)
7+
})
8+
9+
test('initial rendering', async () => {
10+
await expect(page).toMatch('こんにちは、kazupon!')
11+
})
12+
13+
test('change locale', async () => {
14+
await page.select('#app select', 'en')
15+
await expect(page).toMatch('Hello, kazupon!')
16+
})
17+
})
18+
})

e2e/functions/plural.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
;['composition', 'legacy'].forEach(pattern => {
2+
describe(`${pattern}`, () => {
3+
beforeAll(async () => {
4+
await page.goto(
5+
`http://localhost:8080/examples/${pattern}/functions/plural.html`
6+
)
7+
})
8+
9+
test('initial rendering', async () => {
10+
await expect(page).toMatch('car')
11+
await expect(page).toMatch('cars')
12+
await expect(page).toMatch('no apples')
13+
await expect(page).toMatch('one apple')
14+
await expect(page).toMatch('10 apples')
15+
await expect(page).toMatch('1 banana')
16+
await expect(page).toMatch('too many bananas')
17+
})
18+
})
19+
})

examples/composition/formatting/list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset="utf-8" />
5-
<title>List formatting example</title>
5+
<title>List interpolation example</title>
66
<script src="../../../node_modules/vue/dist/vue.global.js"></script>
77
<script src="../../../dist/vue-i18n.global.js"></script>
88
</head>

examples/composition/formatting/literal.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset="utf-8" />
5-
<title>Literal example</title>
5+
<title>Literal interpolation example</title>
66
<script src="../../../node_modules/vue/dist/vue.global.js"></script>
77
<script src="../../../dist/vue-i18n.global.js"></script>
88
</head>

examples/composition/formatting/named.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset="utf-8" />
5-
<title>Named formatting example</title>
5+
<title>Named interpolation example</title>
66
<script src="../../../node_modules/vue/dist/vue.global.js"></script>
77
<script src="../../../dist/vue-i18n.global.js"></script>
88
</head>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Example: Linked message with message function</title>
6+
<script src="../../../node_modules/vue/dist/vue.global.js"></script>
7+
<script src="../../../dist/vue-i18n.global.js"></script>
8+
</head>
9+
<body>
10+
<div id="app">
11+
<form>
12+
<label>{{ t('message.language') }}</label>
13+
<select v-model="locale">
14+
<option value="en">en</option>
15+
<option value="ja">ja</option>
16+
</select>
17+
</form>
18+
<p>{{ t('message.linked') }}</p>
19+
<label>{{ t('message.homeAddress') }}</label>
20+
<p class="error">{{ t('message.missingHomeAddress') }}</p>
21+
<p>{{ t('message.custom_modifier', { snake: 'message.snake' }) }}</p>
22+
</div>
23+
<script>
24+
const { createApp } = Vue
25+
const { createI18n, useI18n } = VueI18n
26+
27+
const i18n = createI18n({
28+
legacy: false,
29+
locale: 'en',
30+
messages: {
31+
en: {
32+
message: {
33+
language: 'Language',
34+
the_world: 'the world',
35+
dio: 'DIO:',
36+
// '@:message.dio @:message.the_world !!!!'
37+
linked: ({ linked }) => `${linked('message.dio')} ${linked('message.the_world')} !!!!`,
38+
homeAddress: 'Home address',
39+
// 'Please provide @.lower:message.homeAddress'
40+
missingHomeAddress: ({ linked }) => `Please provide ${linked('message.homeAddress', 'lower')}`,
41+
snake: 'snake case',
42+
// "custom modifiers example: @.snakeCase:{'message.snake'}"
43+
custom_modifier: ({ linked }) => `custom modifiers example: ${linked('message.snake', 'snakeCase')}`
44+
}
45+
},
46+
ja: {
47+
message: {
48+
language: '言語',
49+
the_world: 'ザ・ワールド',
50+
dio: 'ディオ:',
51+
// '@:message.dio @:message.the_world !!!!'
52+
linked: ({ linked }) => `${linked('message.dio')} ${linked('message.the_world')} !!!!`,
53+
homeAddress: 'ホームアドレス',
54+
// 'どうか、@.lower:message.homeAddress を提供してください。'
55+
missingHomeAddress: ({ linked }) => `どうか、${linked('message.homeAddress', 'lower')} を提供してください。`,
56+
snake: 'スネーク ケース',
57+
// "カスタム修飾子の例: @.snakeCase:{'message.snake'}"
58+
custom_modifier: ({ linked }) => `カスタム修飾子の例: ${linked('message.snake', 'snakeCase')}`
59+
}
60+
}
61+
},
62+
modifiers: {
63+
snakeCase: str => str.split(' ').join('-')
64+
}
65+
})
66+
67+
const app = createApp({
68+
setup() {
69+
const { t, locale } = useI18n()
70+
71+
// Something to do ...
72+
//
73+
74+
return { t, locale }
75+
}
76+
})
77+
app.use(i18n)
78+
app.mount('#app')
79+
</script>
80+
</body>
81+
</html>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Example: List interpolation with Message Function</title>
6+
<script src="../../../node_modules/vue/dist/vue.global.js"></script>
7+
<script src="../../../dist/vue-i18n.global.js"></script>
8+
</head>
9+
<body>
10+
<div id="app">
11+
<form>
12+
<label>{{ t('message.language') }}</label>
13+
<select v-model="locale">
14+
<option value="en">en</option>
15+
<option value="ja">ja</option>
16+
</select>
17+
</form>
18+
<p>{{ t('message.greeting', ['kazupon']) }}</p>
19+
</div>
20+
<script>
21+
const { createApp } = Vue
22+
const { createI18n, useI18n } = VueI18n
23+
24+
const i18n = createI18n({
25+
legacy: false,
26+
locale: 'ja',
27+
messages: {
28+
en: {
29+
message: {
30+
language: 'Language',
31+
greeting: ctx => `Hello, ${ctx.list(0)}!`
32+
}
33+
},
34+
ja: {
35+
message: {
36+
language: '言語',
37+
greeting: ctx => `こんにちは、${ctx.list(0)}!`
38+
}
39+
}
40+
}
41+
})
42+
43+
const app = createApp({
44+
setup() {
45+
const { t, locale } = useI18n()
46+
47+
// Something to do ...
48+
//
49+
50+
return { t, locale }
51+
}
52+
})
53+
app.use(i18n)
54+
app.mount('#app')
55+
</script>
56+
</body>
57+
</html>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Example: Named interpolatino with message function</title>
6+
<script src="../../../node_modules/vue/dist/vue.global.js"></script>
7+
<script src="../../../dist/vue-i18n.global.js"></script>
8+
</head>
9+
<body>
10+
<div id="app">
11+
<form>
12+
<label>{{ t('message.language') }}</label>
13+
<select v-model="locale">
14+
<option value="en">en</option>
15+
<option value="ja">ja</option>
16+
</select>
17+
</form>
18+
<p>{{ t('message.greeting', { name: 'kazupon' }) }}</p>
19+
</div>
20+
<script>
21+
const { createApp } = Vue
22+
const { createI18n, useI18n } = VueI18n
23+
24+
const i18n = createI18n({
25+
legacy: false,
26+
locale: 'ja',
27+
messages: {
28+
en: {
29+
message: {
30+
language: 'Language',
31+
greeting: ctx => `Hello, ${ctx.named('name')}!`
32+
}
33+
},
34+
ja: {
35+
message: {
36+
language: '言語',
37+
greeting: ctx => `こんにちは、${ctx.named('name')}!`
38+
}
39+
}
40+
}
41+
})
42+
43+
const app = createApp({
44+
setup() {
45+
const { t, locale } = useI18n()
46+
47+
// Something to do ...
48+
//
49+
50+
return { t, locale }
51+
}
52+
})
53+
app.use(i18n)
54+
app.mount('#app')
55+
</script>
56+
</body>
57+
</html>

0 commit comments

Comments
 (0)