Skip to content

Commit 89c9e30

Browse files
authored
Japanese translation (~essential) (#449)
* add Japanese config * add ja-translation (home, introduction, install, essential)
1 parent 57cdea8 commit 89c9e30

26 files changed

+5473
-125
lines changed

docs/.vitepress/config.js

Lines changed: 312 additions & 125 deletions
Large diffs are not rendered by default.

docs/ja/api/injection.md

Lines changed: 1282 additions & 0 deletions
Large diffs are not rendered by default.

docs/ja/ecosystem/official.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Official tooling
2+
3+
## Vue CLI Plugin
4+
5+
[vue-cli-plugin-i18n](https://github.com/kazupon/vue-cli-plugin-i18n) is officially provided as the Vue CLI Plugin.
6+
7+
With this plugin, you can setup the i18n environment for the Vue application, and support the i18n development environment.
8+
9+
## ESLint Plugin
10+
11+
[eslint-plugin-vue-i18n](https://intlify.github.io/eslint-plugin-vue-i18n/) is ESLint plugin for Vue I18n.
12+
13+
It easily integrates some localization lint features to your Vue.js Application.
14+
15+
## Intlify CLI
16+
17+
[@intlify/cli](https://github.com/intlify/cli) is CLI Tooling for i18n development.
18+
19+
You can pre-compile i18n resources (`json5?`, `ya?ml`) with `intlify compile` command.
20+
21+
## Extensions
22+
23+
[vue-i18n-extensions](https://github.com/intlify/vue-i18n-extensions) provides some extensions for Vue I18n.
24+
25+
You can use this extension to enable SSR and improve i18n performance.
26+
27+
## Composition API for Vue 2.x
28+
29+
[vue-i18n-composable](https://github.com/intlify/vue-i18n-composable) provides Composition API for Vue I18n in Vue 2.x.

docs/ja/ecosystem/third.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Third-party tooling
2+
3+
## Nuxt Module
4+
5+
[nuxt-i18n](https://github.com/nuxt-community/nuxt-i18n/) is corresponding Nuxt.js module.
6+
7+
:::warning NOTICE
8+
Still not supported.
9+
:::
10+
11+
## BabelEdit
12+
13+
[BabelEdit](https://www.codeandweb.com/babeledit) is translation editor for web apps.
14+
15+
BabelEdit can translate `json` files, and it can also translate `i18n` custom block of Single-file components.
16+
17+
Read more about BabelEdit in [tutorial page](https://www.codeandweb.com/babeledit/tutorials/how-to-translate-your-vue-app-with-vue-i18n).
18+
19+
## i18n Ally
20+
21+
[i18n Ally](https://marketplace.visualstudio.com/items?itemName=antfu.i18n-ally) is i18n extension for VSCode.
22+
23+
The i18n Ally give awesome developer experience for your i18n development.
24+
25+
Read more about i18n Ally in [README](https://github.com/antfu/i18n-ally/blob/master/README.md).
26+
27+
## i18nPlugin (intellij platform)
28+
29+
[i18nPlugin](https://github.com/nyavro/i18nPlugin) Intellij idea i18next support plugin ( [JetBrains plugin page ](https://plugins.jetbrains.com/plugin/12981-i18n-support)).
30+
31+
Plugin for i18n typescript/javascript/PHP. Supports vue-i18n. To enable vue-i18n support go to settings -> Tools -> i18n Plugin configuration and check "Vue-i18n". You need set vue locales directory (locales by default).
32+
33+
## Easy I18n (intellij platform)
34+
35+
Translation helper for IntelliJ IDEA based IDE's. Requires dedicated language files. Features: `Tree-/Table-View` / `Search filter` / `Indication of missing translations` / `Quick CRUD operations`.
36+
37+
[JetBrains Marketplace](https://plugins.jetbrains.com/plugin/16316-easy-i18n) // [GitHub Repository](https://github.com/marhali/easy-i18n)
38+
39+
## vue-i18n-extract
40+
41+
[vue-i18n-extract](https://github.com/pixari/vue-i18n-extract) performs static analysis on a Vue.js project based on vue-i18n and reports the following information:
42+
43+
- list of all the **unused vue-i18n keys** (entries found in the language files but not used in the project)
44+
- list of all the **missing keys** (entries fond in the project but not in the language files)
45+
46+
It’s possible to show the output in the console or to write it in a json file.
47+
48+
The missing keys can be also automatically added to the given language files.
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
# Component Interpolation
2+
3+
## Basic Usage
4+
5+
Sometimes, we need to localize with a locale message that was included in a HTML tag or component. For example:
6+
7+
```html
8+
<p>I accept xxx <a href="/term">Terms of Service Agreement</a></p>
9+
```
10+
11+
In the above message, if you use `$t`, you will probably try to compose the following locale messages:
12+
13+
```js
14+
const messages = {
15+
en: {
16+
term1: 'I Accept xxx\'s',
17+
term2: 'Terms of Service Agreement'
18+
}
19+
}
20+
```
21+
22+
And your localized template may look like this:
23+
24+
```html
25+
<p>{{ $t('term1') }}<a href="/term">{{ $t('term2') }}</a></p>
26+
```
27+
28+
Output:
29+
30+
```html
31+
<p>I accept xxx <a href="/term">Terms of Service Agreement</a></p>
32+
```
33+
34+
This is very cumbersome, and if you configure the `<a>` tag in a locale message, there is a possibility of XSS vulnerabilities due to localizing with `v-html="$t('term')"`.
35+
36+
You can avoid it using the Translation component (`i18n-t`). For example the below.
37+
38+
Template:
39+
40+
```html
41+
<div id="app">
42+
<!-- ... -->
43+
<i18n-t keypath="term" tag="label" for="tos">
44+
<a :href="url" target="_blank">{{ $t('tos') }}</a>
45+
</i18n-t>
46+
<!-- ... -->
47+
</div>
48+
```
49+
50+
JavaScript:
51+
52+
```js
53+
import { createApp } from 'vue'
54+
import { createI18n } from 'vue-i18n'
55+
56+
const i18n = createI18n({
57+
locale: 'en',
58+
messages: {
59+
en: {
60+
tos: 'Term of Service',
61+
term: 'I accept xxx {0}.'
62+
},
63+
ja: {
64+
tos: '利用規約',
65+
term: '私は xxx の{0}に同意します。'
66+
}
67+
}
68+
})
69+
70+
const app = createApp({
71+
data: () => ({ url: '/term' })
72+
})
73+
74+
app.use(i18n)
75+
app.mount('#app')
76+
```
77+
78+
The following output:
79+
80+
```html
81+
<div id="app">
82+
<!-- ... -->
83+
<label for="tos">
84+
I accept xxx <a href="/term" target="_blank">Term of Service</a>.
85+
</label>
86+
<!-- ... -->
87+
</div>
88+
```
89+
90+
About the above example, see the [example](https://github.com/intlify/vue-i18n-next/blob/master/examples/legacy/components/translation.html)
91+
92+
The children of translation component are interpolated with locale message of `keypath` prop. In the above example,
93+
94+
:::v-pre
95+
`<a :href="url" target="_blank">{{ $t('tos') }}</a>`
96+
:::
97+
98+
Is interpolated with `term` locale message.
99+
100+
In the above example, the component interpolation follows the **list interpolation**. The children of translation component are interpolated by their order of appearance.
101+
102+
<!-- textlint-disable -->
103+
You can choose the root node element type by specifying a `tag` prop. If omitted, it defaults to [Fragments](https://v3.vuejs.org/guide/migration/fragments.html#overview).
104+
<!-- textlint-enable -->
105+
106+
## Slots syntax usage
107+
108+
It’s more convenient to use the named slots syntax. For example the below:
109+
110+
Template:
111+
112+
```html
113+
<div id="app">
114+
<!-- ... -->
115+
<i18n-t keypath="info" tag="p">
116+
<template v-slot:limit>
117+
<span>{{ changeLimit }}</span>
118+
</template>
119+
<template v-slot:action>
120+
<a :href="changeUrl">{{ $t('change') }}</a>
121+
</template>
122+
</i18n-t>
123+
<!-- ... -->
124+
</div>
125+
```
126+
127+
JavaScript:
128+
129+
```js
130+
import { createApp } from 'vue'
131+
import { createI18n } from 'vue-i18n'
132+
133+
const i18n = createI18n({
134+
locale: 'en',
135+
messages: {
136+
en: {
137+
info: 'You can {action} until {limit} minutes from departure.',
138+
change: 'change your flight',
139+
refund: 'refund the ticket'
140+
}
141+
}
142+
})
143+
144+
const app = createApp({
145+
data: () => ({
146+
changeUrl: '/change',
147+
refundUrl: '/refund',
148+
changeLimit: 15,
149+
refundLimit: 30
150+
})
151+
})
152+
153+
app.use(i18)
154+
app.mount('#app')
155+
```
156+
157+
Outputs:
158+
159+
```html
160+
<div id="app">
161+
<!-- ... -->
162+
<p>
163+
You can <a href="/change">change your flight</a> until <span>15</span> minutes from departure.
164+
</p>
165+
<!-- ... -->
166+
</div>
167+
```
168+
169+
You can also use the following slots shorthand in templates:
170+
171+
```html
172+
<div id="app">
173+
<!-- ... -->
174+
<i18n-t keypath="info" tag="p">
175+
<template #limit>
176+
<span>{{ changeLimit }}</span>
177+
</template>
178+
<template #action>
179+
<a :href="changeUrl">{{ $t('change') }}</a>
180+
</template>
181+
</i18n-t>
182+
<!-- ... -->
183+
</div>
184+
```
185+
186+
:::warning LIMITATION
187+
:warning: In translation component, slots props are not supported.
188+
:::
189+
190+
### Pluralization Usage
191+
192+
You can use pluralization in Component interpolation by use `plural` prop. For example the below.
193+
194+
Template:
195+
196+
```html
197+
<div id="app">
198+
<!-- ... -->
199+
<i18n-t keypath="message.plural" locale="en" :plural="count">
200+
<template #n>
201+
<b>{{ count }}</b>
202+
</template>
203+
</i18n-t>
204+
<!-- ... -->
205+
</div>
206+
```
207+
208+
JavaScript:
209+
210+
```js
211+
const { createApp, ref } = Vue
212+
const { createI18n } = VueI18n
213+
214+
const i18n = createI18n({
215+
legacy: false,
216+
locale: 'en',
217+
messages: {
218+
en: {
219+
message: {
220+
plural: 'no bananas | {n} banana | {n} bananas'
221+
}
222+
}
223+
}
224+
})
225+
226+
const app = createApp({
227+
setup() {
228+
const count = ref(2)
229+
return { count }
230+
}
231+
})
232+
app.use(i18n)
233+
app.mount('#app')
234+
```
235+
236+
The following output:
237+
```html
238+
<div id="app" data-v-app="">
239+
<!-- ... -->
240+
<b>2</b> bananas
241+
<!-- ... -->
242+
</div>
243+
```

0 commit comments

Comments
 (0)