forked from nuxt-modules/i18n
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(docs): describe per-component translations in more friendly way
- Loading branch information
Showing
3 changed files
with
64 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
title: Per-component translations | ||
description: "enable vue-i18n-loader" | ||
position: 13 | ||
category: Guía | ||
--- | ||
|
||
If you'd like to define translations per-page or per-component you can take advantage of the [vue-i18n-loader](https://github.com/intlify/vue-i18n-loader). Simply set `vueI18nLoader` option to `true` and `nuxt-i18n` will configure and enable the loader for you, including support for Yaml syntax in the `i18n` blocks. | ||
|
||
```js {}[nuxt.config.js] | ||
['nuxt-i18n', { | ||
vueI18nLoader: true | ||
}] | ||
|
||
``` | ||
|
||
You can now define translations using custom blocks in your Vue files: | ||
|
||
```vue | ||
<i18n> | ||
{ | ||
"en": { | ||
"hello": "hello world!" | ||
}, | ||
"ja": { | ||
"hello": "こんにちは、世界!" | ||
} | ||
} | ||
</i18n> | ||
<template> | ||
<p>{{ $t('hello') }}</p> | ||
</template> | ||
``` | ||
|
||
or using the Yaml syntax: | ||
|
||
```vue | ||
<i18n lang="yaml"> | ||
en: | ||
hello: "hello world!" | ||
ja: | ||
hello: "こんにちは、世界!" | ||
</i18n> | ||
<template> | ||
<p>{{ $t('hello') }}</p> | ||
</template> | ||
``` | ||
|
||
<alert type="info"> | ||
|
||
Read more about `i18n` blocks in https://kazupon.github.io/vue-i18n/guide/sfc.html. | ||
|
||
</alert> |
This file was deleted.
Oops, something went wrong.