Skip to content

Commit 27af566

Browse files
committed
📝 docs: update README
1 parent be2bcc2 commit 27af566

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

README.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,9 @@
2121

2222
the below example that`App.vue` have `i18n` custom block:
2323

24-
### Custom Blocks (Single File Components)
25-
```vue
26-
<i18n>
27-
{
28-
"en": {
29-
"hello": "hello world!"
30-
},
31-
"ja": {
32-
"hello": "こんにちは、世界!"
33-
}
34-
}
35-
</i18n>
24+
### Basic
3625

26+
```vue
3727
<template>
3828
<p>{{ $t('hello') }}</p>
3929
</template>
@@ -44,15 +34,29 @@ export default {
4434
// ...
4535
}
4636
</script>
37+
38+
<i18n>
39+
{
40+
"en": {
41+
"hello": "hello world!"
42+
},
43+
"ja": {
44+
"hello": "こんにちは、世界!"
45+
}
46+
}
47+
</i18n>
4748
```
4849

50+
### Source importing
51+
4952
you also can:
5053

5154
```vue
5255
<i18n src="./myLang.json"></i18n>
5356
```
5457

55-
```json
58+
```json5
59+
// ./myLnag.json
5660
{
5761
"en": {
5862
"hello": "hello world!"
@@ -63,6 +67,27 @@ you also can:
6367
}
6468
```
6569

70+
### Locale definition
71+
72+
You can define locale messages for each locale in single-file components:
73+
74+
```vue
75+
<i18n locale="en">
76+
{
77+
"hello": "hello world!"
78+
}
79+
</i18n>
80+
81+
<i18n locale="ja">
82+
{
83+
"hello": "こんにちは、世界!"
84+
}
85+
</i18n>
86+
```
87+
88+
The above defines two locales, which are merged at target single-file components.
89+
90+
6691
### JavaScript
6792

6893
```javascript

0 commit comments

Comments
 (0)