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

Language persistence longer than session #86

Open
ivanstojkovicapps opened this issue Dec 24, 2015 · 8 comments
Open

Language persistence longer than session #86

ivanstojkovicapps opened this issue Dec 24, 2015 · 8 comments

Comments

@ivanstojkovicapps
Copy link

Hi,

is there a way to persist language longer than session.
If i set another language than my defaultLanguage, every time i refresh the page, it first loads the default language and than switches to selected language (i do that manually, after getting the user settings).
The problem would be solved it would be possible to save cookie longer then session.
I can do that manually, but every time the cookie gets overriden by default language because i have: persistSelection: true.

Here is the config:

app.value('localeConf', {
basePath: 'languages',
defaultLocale: 'en-US',
sharedDictionary: 'common',
fileExtension: '.lang.json',
persistSelection: true,
cookieName: 'COOKIE_LOCALE_LANG',
observableAttrs: new RegExp('^data-(?!ng-|i18n)'),
delimiter: '::'
}).value('localeSupported', [
'en-US',
'de-DE'
]).value('localeFallbacks', {
'en': 'en-US',
'de': 'de-DE'
});

Do you have any suggestions?

best regards Ivan

@doshprompt
Copy link
Owner

@ivanstojkovicapps that's interesting, let me take a look and debug and get back to you, it should store in the cookie and be permanent but if that's not the case I might need to fix something.

Btw, are you loading angular-cookies? What version of ng are you running?

@ivanstojkovicapps
Copy link
Author

Hi,

angular 1.4.2
and i am loading ngCookies

I think the only problem is that the cookie expiration date is session. After the session is finished (on new one started) it doesn't have any data in the cookie and uses the default.

@doshprompt
Copy link
Owner

@ivanstojkovicapps I see, that's interesting as I don't think we set the date anywhere. They might've added it in 1.4.x and I will have to take a look and update the codebase to conform. Thanks!

@ivanstojkovicapps
Copy link
Author

perfect!

@doshprompt
Copy link
Owner

Seems like we are using $cookieStore which is deprecated in 1.4+
Good catch, do you want to submit a PR to use $cookies instead?

@bretkikehara
Copy link
Collaborator

I don't think the issue is cookie store.

@ivanstojkovicapps Please correct if I am wrong, but it seems your user session will clear the cookie at a given interval. If we want to persist the locale beyond the user session, then it has to be set in localStorage or sessionStorage instead of the cookie.

@bretkikehara
Copy link
Collaborator

imo, sessionStorage may suit the requirement, since sessionStorage may store the value longer than desired.

@shubhamkumarnayak
Copy link

still facing the same issue.............

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

4 participants