Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: crash with latest vue-i18n related to using null locale #678

Merged
merged 1 commit into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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