{"action":"created","issue":{"url":"https://api.github.com/repos/gadicc/meteor-messageformat/issues/83","labels_url":"https://api.github.com/repos/gadicc/meteor-messageformat/issues/83/labels{/name}","comments_url":"https://api.github.com/repos/gadicc/meteor-messageformat/issues/83/comments","events_url":"https://api.github.com/repos/gadicc/meteor-messageformat/issues/83/events","html_url":"https://github.com/gadicc/meteor-messageformat/issues/83","id":59476862,"number":83,"title":"server side translation for a client's current locale","user":{"login":"lucazulian","id":3492584,"avatar_url":"https://avatars.githubusercontent.com/u/3492584?v=3","gravatar_id":"","url":"https://api.github.com/users/lucazulian","html_url":"https://github.com/lucazulian","followers_url":"https://api.github.com/users/lucazulian/followers","following_url":"https://api.github.com/users/lucazulian/following{/other_user}","gists_url":"https://api.github.com/users/lucazulian/gists{/gist_id}","starred_url":"https://api.github.com/users/lucazulian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucazulian/subscriptions","organizations_url":"https://api.github.com/users/lucazulian/orgs","repos_url":"https://api.github.com/users/lucazulian/repos","events_url":"https://api.github.com/users/lucazulian/events{/privacy}","received_events_url":"https://api.github.com/users/lucazulian/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/gadicc/meteor-messageformat/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/gadicc/meteor-messageformat/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-02T12:47:22Z","updated_at":"2015-03-05T10:55:22Z","closed_at":null,"body":"I'm doing server side validation on a meteor app and I would like to get error messages back to client, localized in the user language (previously set in the client with mfPkg.setLocale(\"userLanguage\")). How can I accomplish this task in the correct way?\r\nOn server side the messages are not localized and I'm not sure how to handle this case."},"comment":{"url":"https://api.github.com/repos/gadicc/meteor-messageformat/issues/comments/77344357","html_url":"https://github.com/gadicc/meteor-messageformat/issues/83#issuecomment-77344357","issue_url":"https://api.github.com/repos/gadicc/meteor-messageformat/issues/83","id":77344357,"user":{"login":"lucazulian","id":3492584,"avatar_url":"https://avatars.githubusercontent.com/u/3492584?v=3","gravatar_id":"","url":"https://api.github.com/users/lucazulian","html_url":"https://github.com/lucazulian","followers_url":"https://api.github.com/users/lucazulian/followers","following_url":"https://api.github.com/users/lucazulian/following{/other_user}","gists_url":"https://api.github.com/users/lucazulian/gists{/gist_id}","starred_url":"https://api.github.com/users/lucazulian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucazulian/subscriptions","organizations_url":"https://api.github.com/users/lucazulian/orgs","repos_url":"https://api.github.com/users/lucazulian/repos","events_url":"https://api.github.com/users/lucazulian/events{/privacy}","received_events_url":"https://api.github.com/users/lucazulian/received_events","type":"User","site_admin":false},"created_at":"2015-03-05T10:55:22Z","updated_at":"2015-03-05T10:55:22Z","body":"I have a proposal\r\nin **messageformat-server.js** add \r\n\r\n```\r\nMeteor.methods({\r\n    setUserLocale: function(locale) {\r\n        \"use strict\";\r\n        this.connection.locale = locale;\r\n    }\r\n});\r\n```\r\n\r\nin **messageformat-client.js** add \r\n\r\n```\r\nTracker.autorun(function() {\r\n    Meteor.call('setUserLocale', Session.get('locale'));\r\n});\r\n```\r\n\r\nin **messageforma.js** change the first part of mf function like this\r\n\r\n```\r\nmf = function(key, params, message, locale) {\r\n    if (!locale && Meteor.isClient)\r\n        locale = Session.get('locale');\r\n \tif (!locale && Meteor.isServer){\r\n\t\tvar currentInvocation = DDP._CurrentInvocation.get();\r\n      \tif (currentInvocation) {\r\n\t\t\tlocale = currentInvocation.connection.locale\r\n      \t}\r\n \t}\r\n    \r\n    if (!locale) {\r\n        locale = mfPkg.native;\r\n    }\r\n```\r\nIn this way I can use mf in server code without track the language of the use in the UI. Did that all make sense? :)"}}