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

Use window.navigator.language if no language cookie is set. #53

Merged
merged 2 commits into from
Jul 23, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ angular.module('ngLocalize')
return currentLocale;
}

setLocale(cookieStore ? cookieStore.get(localeConf.cookieName) : $window.navigator.userLanguage || $window.navigator.language);
setLocale(cookieStore.get(localeConf.cookieName) ? cookieStore.get(localeConf.cookieName) : $window.navigator.userLanguage || $window.navigator.language);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setLocale(cookieStore && cookieStore.get(localeConf.cookieName) ? /* ... */);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would cookieStore evaluate to false and cookieStore.get(localeConf.cookieName) evaluate to true? If cookieStore is false then cookieStore.get(localeConf.cookieName) will definitely be false as well. Seems like an unnecessary check. Am I overlooking something?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If cookieStore doesn't exist, referencing cookieStore.get will cause an error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay. Better safe than sorry! Thanks!


return {
ready: ready,
Expand Down