Skip to content

Commit

Permalink
Merge pull request nuxt-modules#288 from DansMaCulotte/master
Browse files Browse the repository at this point in the history
Global options configuration
  • Loading branch information
paulgv authored May 5, 2019
2 parents dc66895 + 6574e14 commit b51aed6
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 55 deletions.
36 changes: 19 additions & 17 deletions docs/basic-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@ The fastest way to get started with **nuxt-i18n** is to define the supported `lo
```js
{
modules: [
['nuxt-i18n', {
locales: ['en', 'fr', 'es'],
defaultLocale: 'en',
vueI18n: {
fallbackLocale: 'en',
messages: {
en: {
welcome: 'Welcome'
},
fr: {
welcome: 'Bienvenue'
},
es: {
welcome: 'Bienvenido'
}
'nuxt-i18n'
],

i18n: {
locales: ['en', 'fr', 'es'],
defaultLocale: 'en',
vueI18n: {
fallbackLocale: 'en',
messages: {
en: {
welcome: 'Welcome'
},
fr: {
welcome: 'Bienvenue'
},
es: {
welcome: 'Bienvenido'
}
}
}]
]
}
}
}
```

Expand Down
12 changes: 8 additions & 4 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ Then add the module to `nuxt.config.js`:
```js
{
modules: [
['nuxt-i18n', {
// Options
}]
]
[
'nuxt-i18n',
{ /* module options */ }
]
],

// Or with global options
i18n: {}
}
```

Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = function (userOptions) {
const pluginsPath = join(__dirname, PLUGINS_DIR)
const templatesPath = join(__dirname, TEMPLATES_DIR)
const requiredPlugins = ['main', 'routing']
const options = { ...DEFAULT_OPTIONS, ...userOptions }
const options = { ...DEFAULT_OPTIONS, ...userOptions, ...this.options.i18n }
// Options that have nested config options must be merged
// individually with defaults to prevent missing options
for (const key of NESTED_OPTIONS) {
Expand Down
65 changes: 32 additions & 33 deletions test/fixtures/basic/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,38 @@ module.exports = {
render: {
resourceHints: false
},
modules: [
['@@', {
seo: true,
baseUrl: 'nuxt-app.localhost',
locales: [
{
code: 'en',
iso: 'en-US',
name: 'English'
modules: ['@@'],
i18n: {
seo: true,
baseUrl: 'nuxt-app.localhost',
locales: [
{
code: 'en',
iso: 'en-US',
name: 'English'
},
{
code: 'fr',
iso: 'fr-FR',
name: 'Français'
}
],
defaultLocale: 'en',
lazy: false,
vueI18n: {
messages: {
fr: {
home: 'Accueil',
about: 'À propos',
posts: 'Articles'
},
{
code: 'fr',
iso: 'fr-FR',
name: 'Français'
en: {
home: 'Homepage',
about: 'About us',
posts: 'Posts'
}
],
defaultLocale: 'en',
lazy: false,
vueI18n: {
messages: {
fr: {
home: 'Accueil',
about: 'À propos',
posts: 'Articles'
},
en: {
home: 'Homepage',
about: 'About us',
posts: 'Posts'
}
},
fallbackLocale: 'en'
}
}]
]
},
fallbackLocale: 'en'
}
}
}

0 comments on commit b51aed6

Please sign in to comment.