Skip to content

Commit

Permalink
fix: crash with latest vue-i18n related to using null locale (#678)
Browse files Browse the repository at this point in the history
More details in kazupon/vue-i18n#849
  • Loading branch information
rchl authored Apr 23, 2020
1 parent e795765 commit 642fddf
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"cookie": "^0.4.0",
"is-https": "^1.0.0",
"js-cookie": "^2.2.1",
"vue-i18n": "8.16.0",
"vue-i18n": "^8.17.3",
"vue-i18n-extensions": "^0.2.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exports.DEFAULT_OPTIONS = {
vueI18n: {},
vueI18nLoader: false,
locales: [],
defaultLocale: null,
defaultLocale: '',
routesNameSeparator: '___',
defaultLocaleRouteNameSuffix: 'default',
strategy: STRATEGIES.PREFIX_EXCEPT_DEFAULT,
Expand All @@ -38,7 +38,7 @@ exports.DEFAULT_OPTIONS = {
cookieDomain: null,
cookieKey: 'i18n_redirected',
alwaysRedirect: false,
fallbackLocale: null
fallbackLocale: ''
},
differentDomains: false,
seo: false,
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ export default async (context) => {
const vueI18nOptions = typeof vueI18n === 'function' ? vueI18n(context) : vueI18n
app.i18n = new VueI18n(vueI18nOptions)
// Initialize locale and fallbackLocale as vue-i18n defaults those to 'en-US' if falsey
app.i18n.locale = null
app.i18n.fallbackLocale = vueI18nOptions.fallbackLocale || null
app.i18n.locale = ''
app.i18n.fallbackLocale = vueI18nOptions.fallbackLocale || ''
app.i18n.locales = locales
app.i18n.defaultLocale = defaultLocale
app.i18n.differentDomains = differentDomains
Expand All @@ -218,7 +218,7 @@ export default async (context) => {
}
}

let locale = app.i18n.defaultLocale || null
let locale = app.i18n.defaultLocale || ''

if (vuex && vuex.syncLocale && store && store.state[vuex.moduleName].locale !== '') {
locale = store.state[vuex.moduleName].locale
Expand Down
2 changes: 1 addition & 1 deletion src/templates/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ middleware.nuxti18n = async (context) => {
return
}

const locale = app.i18n.locale || app.i18n.defaultLocale || null
const locale = app.i18n.locale || app.i18n.defaultLocale || ''
const routeLocale = getLocaleFromRoute(route)

await app.i18n.setLocale(routeLocale || locale)
Expand Down
2 changes: 1 addition & 1 deletion types/nuxt-i18n.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ declare namespace NuxtVueI18n {
// options that are also exposed on VueI18n instance: https://goo.gl/UwNfZo
interface NuxtI18nInterface {
beforeLanguageSwitch?: (oldLocale: string, newLocale: string) => void
defaultLocale?: null | Locale
defaultLocale?: Locale
locales?: Array<Locale | LocaleObject>
differentDomains?: boolean
forwardedHost?: boolean
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13505,10 +13505,10 @@ vue-i18n-extensions@^0.2.1:
resolved "https://registry.yarnpkg.com/vue-i18n-extensions/-/vue-i18n-extensions-0.2.1.tgz#86ebea45a1f9c9594cd124f264e107aea193d7dd"
integrity sha512-xBrItI7bEwBnG7eAlnyUARP41JYYn2+ABMR8q1Yh5FM9hHCbs4XPZwG+4+FPeIZ6b5gYk4YUP//m+fWiuU9z9A==

vue-i18n@8.16.0:
version "8.16.0"
resolved "https://registry.yarnpkg.com/vue-i18n/-/vue-i18n-8.16.0.tgz#f84188a36a4cc3c876427b869c7c5a82d6696080"
integrity sha512-cp9JOsx4ETzlCsnD22FE8ZhAmD8kcyNLRKV0DPsS7bBNTCdIlOKuyTGonWKYcGCUtNMtwemDWRBevRm8eevBVg==
vue-i18n@^8.17.3:
version "8.17.3"
resolved "https://registry.yarnpkg.com/vue-i18n/-/vue-i18n-8.17.3.tgz#f366082d5784c3c35e8ffda733cb3f3990a3900d"
integrity sha512-sWjGOL7dXo6rYcPQmlY8FN/beLxq2aCnTZMSxfW0yW78rRGpqWrqXJURH56kvMYCnyNCepBjGWEEW0rbFiig5Q==

vue-loader@^15.7.1, vue-loader@^15.9.1:
version "15.9.1"
Expand Down

0 comments on commit 642fddf

Please sign in to comment.