Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fallbackLocale): support vue-i18n decision map fallback (#992)
- Loading branch information
1 parent
2e1259e
commit b4c6cfd
Showing
18 changed files
with
324 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
title: Locale fallback | ||
description: "How a fallback gets selected when a translation is missing" | ||
position: 12 | ||
category: Guide | ||
--- | ||
|
||
**nuxt-i18n** takes advantage of **vue-i18n** ability to handle localization fallback. It is possible to define a single fallback locale, an array of locales, | ||
or a decision map for more specific needs. | ||
|
||
```js [nuxt.config.js] | ||
modules: [ | ||
'nuxt-i18n' | ||
], | ||
|
||
i18n: { | ||
vueI18n: { | ||
fallbackLocale: 'en', | ||
// or | ||
fallbackLocale: ['en', 'fr'], | ||
// or | ||
fallbackLocale: { | ||
'de-CH': ['fr', 'it'], | ||
'zh-Hant': ['zh-Hans'], | ||
'es-CL': ['es-AR'], | ||
'es': ['en-GB'], | ||
'pt': ['es-AR'], | ||
'default': ['en', 'da'] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
More information in [vue-i18n documentation](https://kazupon.github.io/vue-i18n/guide/fallback.html). |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
--- | ||
title: vue-i18n-loader | ||
description: "enable vue-i18n-loader" | ||
position: 12 | ||
position: 13 | ||
category: Guide | ||
--- | ||
|
||
|
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
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,34 @@ | ||
--- | ||
title: Locale fallback | ||
description: "How a fallback gets selected when a translation is missing" | ||
position: 12 | ||
category: Guía | ||
--- | ||
|
||
**nuxt-i18n** takes advantage of **vue-i18n** ability to handle localization fallback. It is possible to define a single fallback locale, an array of locales, | ||
or a decision map for more specific needs. | ||
|
||
```js [nuxt.config.js] | ||
modules: [ | ||
'nuxt-i18n' | ||
], | ||
|
||
i18n: { | ||
vueI18n: { | ||
fallbackLocale: 'en', | ||
// or | ||
fallbackLocale: ['en', 'fr'], | ||
// or | ||
fallbackLocale: { | ||
'de-CH': ['fr', 'it'], | ||
'zh-Hant': ['zh-Hans'], | ||
'es-CL': ['es-AR'], | ||
'es': ['en-GB'], | ||
'pt': ['es-AR'], | ||
'default': ['en', 'da'] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
More information in [vue-i18n documentation](https://kazupon.github.io/vue-i18n/guide/fallback.html). |
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
--- | ||
title: vue-i18n-loader | ||
description: 'vue-i18n-loader' | ||
position: 10 | ||
position: 13 | ||
category: Guía | ||
--- | ||
|
||
|
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,3 @@ | ||
export default { | ||
deKey: 'de translation' | ||
} |
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,3 @@ | ||
export default { | ||
enGBKey: 'en-GB translation' | ||
} |
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,3 @@ | ||
export default { | ||
esKey: 'es translation' | ||
} |
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,3 @@ | ||
export default { | ||
frFRKey: 'fr-FR translation' | ||
} |
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,12 @@ | ||
import { resolve } from 'path' | ||
import BaseConfig from '../base.config' | ||
|
||
/** @type {import('@nuxt/types').NuxtConfig} */ | ||
const config = { | ||
...BaseConfig, | ||
|
||
buildDir: resolve(__dirname, '.nuxt'), | ||
srcDir: __dirname | ||
} | ||
|
||
module.exports = config |
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,8 @@ | ||
<template> | ||
<div> | ||
<p data-test="fr-key">{{ $t('frFRKey') }}</p> | ||
<p data-test="en-gb-key">{{ $t('enGBKey') }}</p> | ||
<p data-test="es-key">{{ $t('esKey') }}</p> | ||
<p data-test="de-key">{{ $t('deKey') }}</p> | ||
</div> | ||
</template> |
Oops, something went wrong.