{"action":"created","issue":{"url":"https://api.github.com/repos/mashpie/i18n-node/issues/237","repository_url":"https://api.github.com/repos/mashpie/i18n-node","labels_url":"https://api.github.com/repos/mashpie/i18n-node/issues/237/labels{/name}","comments_url":"https://api.github.com/repos/mashpie/i18n-node/issues/237/comments","events_url":"https://api.github.com/repos/mashpie/i18n-node/issues/237/events","html_url":"https://github.com/mashpie/i18n-node/issues/237","id":154654954,"number":237,"title":"How to change locale through the language picker","user":{"login":"iaptsiauri","id":9304536,"avatar_url":"https://avatars.githubusercontent.com/u/9304536?v=3","gravatar_id":"","url":"https://api.github.com/users/iaptsiauri","html_url":"https://github.com/iaptsiauri","followers_url":"https://api.github.com/users/iaptsiauri/followers","following_url":"https://api.github.com/users/iaptsiauri/following{/other_user}","gists_url":"https://api.github.com/users/iaptsiauri/gists{/gist_id}","starred_url":"https://api.github.com/users/iaptsiauri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iaptsiauri/subscriptions","organizations_url":"https://api.github.com/users/iaptsiauri/orgs","repos_url":"https://api.github.com/users/iaptsiauri/repos","events_url":"https://api.github.com/users/iaptsiauri/events{/privacy}","received_events_url":"https://api.github.com/users/iaptsiauri/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-13T08:01:26Z","updated_at":"2016-05-13T08:37:14Z","closed_at":null,"body":"This is my configuration but locale doesn't change, if I change defalutLocale in initial configuration webpage is translated. But if I pick different language from the dropdown nothing changes\r\n\r\n```\r\ni18n.configure({\r\n  locales: ['eng', 'rus'],\r\n  defaultLocale: 'rus',\r\n  directory: __dirname + '/static/locales',\r\n  cookiename: 'locale'\r\n});\r\n\r\napp.use(function (req, res, next) {\r\n    res.locals.__ = res.__ = function() {\r\n        return i18n.__.apply(req, arguments);\r\n    };\r\n    next();\r\n});\r\n\r\napp.get('/:locale', function (req, res) {\r\n    res.cookie('locale', req.params.locale);\r\n    i18n.setLocale(i18n, req.params.locale);\r\n    res.redirect(req.headers.referer);\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/mashpie/i18n-node/issues/comments/218983984","html_url":"https://github.com/mashpie/i18n-node/issues/237#issuecomment-218983984","issue_url":"https://api.github.com/repos/mashpie/i18n-node/issues/237","id":218983984,"user":{"login":"mashpie","id":118508,"avatar_url":"https://avatars.githubusercontent.com/u/118508?v=3","gravatar_id":"","url":"https://api.github.com/users/mashpie","html_url":"https://github.com/mashpie","followers_url":"https://api.github.com/users/mashpie/followers","following_url":"https://api.github.com/users/mashpie/following{/other_user}","gists_url":"https://api.github.com/users/mashpie/gists{/gist_id}","starred_url":"https://api.github.com/users/mashpie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mashpie/subscriptions","organizations_url":"https://api.github.com/users/mashpie/orgs","repos_url":"https://api.github.com/users/mashpie/repos","events_url":"https://api.github.com/users/mashpie/events{/privacy}","received_events_url":"https://api.github.com/users/mashpie/received_events","type":"User","site_admin":false},"created_at":"2016-05-13T08:37:14Z","updated_at":"2016-05-13T08:37:14Z","body":"3 things to consider:\r\n\r\n1. does your cookie get set correctly, like you try with `res.cookie('locale', req.params.locale);`\r\n2. I am missing any `app.use(cookieParser());` `app.use(i18n.init)` (https://github.com/mashpie/i18n-node/blob/master/examples/express4-cookie/index.js#L13) in your listing which are needed to parse cookies from request and initialize i18n with their value.\r\n3. your `i18n.setLocale(i18n, req.params.locale);` is useless and wrong. Setting the cookie and redirecting should do job. And if you need to use setLocale you should pass the correct object (https://github.com/mashpie/i18n-node#i18nsetlocale) like so `i18n.setLocale(req, req.params.locale);` But this, again only affects the current request until redirecttion.\r\n\r\nAnd another note :) your binding of helpers is done by i18n.init(), too. So you won't need to that by yourself. So all in all it should read like so:\r\n\r\n```js\r\ni18n.configure({\r\n  locales: ['eng', 'rus'],\r\n  defaultLocale: 'rus',\r\n  directory: __dirname + '/static/locales',\r\n  cookiename: 'locale'\r\n});\r\n\r\n// beware of the order\r\napp.use(cookieParser());\r\napp.use(i18n.init);\r\n\r\napp.get('/:locale', function (req, res) {\r\n  res.cookie('locale', req.params.locale);\r\n  res.redirect(req.headers.referer);\r\n});\r\n```"}}