Skip to content

Commit 142dcb0

Browse files
michaelwnycpaulgv
authored andcommitted
fix: State not defined (#178)
* Fix state not defined without SSR. * Add preserveState option. * Add docs. Fixes #173
1 parent 235d866 commit 142dcb0

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

docs/options-reference.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Here are all the options available when configuring the module and their default
5858
cookieKey: 'i18n_redirected',
5959
// Set to always redirect to value stored in the cookie, not just once
6060
alwaysRedirect: false,
61-
// If no locale for the browsers locale is a match, use this one as a fallback
61+
// If no locale for the browsers locale is a match, use this one as a fallback
6262
fallbackLocale: null
6363
},
6464

@@ -84,15 +84,18 @@ Here are all the options available when configuring the module and their default
8484
vuex: {
8585
// Module namespace
8686
moduleName: 'i18n',
87-
87+
8888
// Mutations config
8989
mutations: {
9090
// Mutation to commit to store current locale, set to false to disable
9191
setLocale: 'I18N_SET_LOCALE',
9292

9393
// Mutation to commit to store current message, set to false to disable
9494
setMessages: 'I18N_SET_MESSAGES'
95-
}
95+
},
96+
97+
// PreserveState from server
98+
preserveState: false
9699
},
97100

98101
// By default, custom routes are extracted from page files using acorn parsing,

src/helpers/constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ exports.DEFAULT_OPTIONS = {
4646
mutations: {
4747
setLocale: 'I18N_SET_LOCALE',
4848
setMessages: 'I18N_SET_MESSAGES'
49-
}
49+
},
50+
preserveState: false
5051
},
5152
parsePages: true,
5253
pages: {},

src/plugins/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default async ({ app, route, store, req }) => {
4444
state.messages = messages
4545
}
4646
}
47-
})
47+
}, { preserveState: vuex.preserveState })
4848
}
4949
<% } %>
5050

0 commit comments

Comments
 (0)