Skip to content

Commit

Permalink
fix: State not defined (#178)
Browse files Browse the repository at this point in the history
* Fix state not defined without SSR.

* Add preserveState option.

* Add docs.

Fixes #173
  • Loading branch information
michaelwnyc authored and paulgv committed Jan 14, 2019
1 parent 235d866 commit 142dcb0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
9 changes: 6 additions & 3 deletions docs/options-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Here are all the options available when configuring the module and their default
cookieKey: 'i18n_redirected',
// Set to always redirect to value stored in the cookie, not just once
alwaysRedirect: false,
// If no locale for the browsers locale is a match, use this one as a fallback
// If no locale for the browsers locale is a match, use this one as a fallback
fallbackLocale: null
},

Expand All @@ -84,15 +84,18 @@ Here are all the options available when configuring the module and their default
vuex: {
// Module namespace
moduleName: 'i18n',

// Mutations config
mutations: {
// Mutation to commit to store current locale, set to false to disable
setLocale: 'I18N_SET_LOCALE',

// Mutation to commit to store current message, set to false to disable
setMessages: 'I18N_SET_MESSAGES'
}
},

// PreserveState from server
preserveState: false
},

// By default, custom routes are extracted from page files using acorn parsing,
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ exports.DEFAULT_OPTIONS = {
mutations: {
setLocale: 'I18N_SET_LOCALE',
setMessages: 'I18N_SET_MESSAGES'
}
},
preserveState: false
},
parsePages: true,
pages: {},
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default async ({ app, route, store, req }) => {
state.messages = messages
}
}
})
}, { preserveState: vuex.preserveState })
}
<% } %>

Expand Down

0 comments on commit 142dcb0

Please sign in to comment.