File tree Expand file tree Collapse file tree 5 files changed +12
-1
lines changed Expand file tree Collapse file tree 5 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,8 @@ Aquí están todas las opciones disponibles al configurar el módulo y sus valor
6262 // preferred language to prevent subsequent redirections
6363 // Set to false to redirect every time
6464 useCookie: true ,
65+ // Set to override the default domain of the cookie. Defaults to host of the site.
66+ cookieDomain: null
6567 // Cookie name
6668 cookieKey: ' i18n_redirected' ,
6769 // Set to always redirect to value stored in the cookie, not just once
Original file line number Diff line number Diff line change @@ -62,6 +62,8 @@ Here are all the options available when configuring the module and their default
6262 // preferred language to prevent subsequent redirections
6363 // Set to false to redirect every time
6464 useCookie: true ,
65+ // Set to override the default domain of the cookie. Defaults to host of the site.
66+ cookieDomain: null
6567 // Cookie name
6668 cookieKey: ' i18n_redirected' ,
6769 // Set to always redirect to value stored in the cookie, not just once
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ exports.DEFAULT_OPTIONS = {
3535 rootRedirect : null ,
3636 detectBrowserLanguage : {
3737 useCookie : true ,
38+ cookieDomain : null ,
3839 cookieKey : 'i18n_redirected' ,
3940 alwaysRedirect : false ,
4041 fallbackLocale : null
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ export default async (context) => {
8686 } , { preserveState : ! ! store . state [ vuex . moduleName ] } )
8787 }
8888
89- const { useCookie, cookieKey } = detectBrowserLanguage
89+ const { useCookie, cookieKey, cookieDomain } = detectBrowserLanguage
9090
9191 const getLocaleCookie = ( ) => {
9292 if ( useCookie ) {
@@ -109,6 +109,11 @@ export default async (context) => {
109109 path : '/' ,
110110 sameSite : 'lax'
111111 }
112+
113+ if ( cookieDomain ) {
114+ cookieOptions . domain = cookieDomain
115+ }
116+
112117 if ( process . client ) {
113118 JsCookie . set ( cookieKey , locale , cookieOptions )
114119 } else if ( res ) {
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ declare namespace NuxtVueI18n {
2626
2727 interface DetectBrowserLanguageInterface {
2828 useCookie ?: boolean
29+ cookieDomain ?: string | null
2930 cookieKey ?: string
3031 alwaysRedirect ?: boolean
3132 fallbackLocale ?: Locale | null
You can’t perform that action at this time.
0 commit comments