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

I have an issue when I set up detector with cookie #155

Closed
GuitarHero02 opened this issue Jun 18, 2018 · 2 comments
Closed

I have an issue when I set up detector with cookie #155

GuitarHero02 opened this issue Jun 18, 2018 · 2 comments

Comments

@GuitarHero02
Copy link

I set up react-i18next with i18next-browser-languagedetector in my project
I set up options as usual setting I think
but it doesn't set up cookie only using local storage
how can I set up cookie value in my project
if i make a wrong setting up options could you give me a some advice for me?

import LngDetector from 'i18next-browser-languagedetector';
...

const options = {
order:['cookie', 'header', 'querystring'],
lookupCookie: 'Locale',
lookupQuerystring: 'Locale',
lookupLocalStorage: 'Locale',

// cookieExpirationDate: new Date(),
caches: ['cookie'],
cookieMinutes: 86400000,
cookieDomain: 'http://localhost:30202',
excludeCacheFor: ['cimode']
}

const detector = new LngDetector(null, options);

i18next
.use(XHR)
.use(detector)
.use(reactI18nextModule)
.init({
debug: true,
interpolation: {
// React already does escaping
escapeValue: false,
},
fallbackLng: 'ko',
lng: 'ko', // 'ko' | 'en',
// localStorageExprirationTime: 86400000,
ns: 'translation',
load:'all',
useCookie: true,
// Using simple hardcoded resources for simple example
resGetPath: 'locales/{{lng}}/{{ns}}.json',
},function(err, t){
window.geoip2.country(onSuccess, onError);
})

@GuitarHero02
Copy link
Author

localStorage is working well but cookie doesn't working ;_;

@jamuhl
Copy link
Member

jamuhl commented Jun 18, 2018

looks like you set language on i18next.init -> lng: 'ko' -> which will completely ignore detections - which means only calling i18next.changeLanguage will set cookie later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants