-
-
Notifications
You must be signed in to change notification settings - Fork 325
/
started.html
59 lines (55 loc) · 1.46 KB
/
started.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Getting Started</title>
<script src="../../node_modules/vue/dist/vue.global.js"></script>
<script src="../../packages/vue-i18n/dist/vue-i18n.global.js"></script>
</head>
<body>
<div id="app">
<form>
<label for="locale-select">{{ t('message.language') }}</label>
<select id="locale-select" v-model="locale">
<option value="en">en</option>
<option value="ja">ja</option>
</select>
</form>
<p>{{ t("message.hello") }}</p>
</div>
<script>
const { createApp } = Vue
const { createI18n, useI18n } = VueI18n
const i18n = createI18n({
legacy: false,
locale: 'ja',
messages: {
en: {
message: {
language: 'Language',
hello: 'hello world!'
}
},
ja: {
message: {
language: '言語',
hello: 'こんにちは、世界!'
}
}
}
})
const app = createApp({
setup() {
// `useI18n` return the global composer that is created at `createI18n`
// `useI18n` must to be called at head of `setup` function
const { t, locale } = useI18n()
// Something to do ...
//
return { t, locale }
}
})
app.use(i18n)
app.mount('#app')
</script>
</body>
</html>