{"action":"closed","issue":{"url":"https://api.github.com/repos/angular-translate/angular-translate/issues/1325","labels_url":"https://api.github.com/repos/angular-translate/angular-translate/issues/1325/labels{/name}","comments_url":"https://api.github.com/repos/angular-translate/angular-translate/issues/1325/comments","events_url":"https://api.github.com/repos/angular-translate/angular-translate/issues/1325/events","html_url":"https://github.com/angular-translate/angular-translate/issues/1325","id":121197466,"number":1325,"title":"Bug with: browserify + angular-translate-interpolation-messageformat + loading locale","user":{"login":"ArnaudValensi","id":604486,"avatar_url":"https://avatars.githubusercontent.com/u/604486?v=3","gravatar_id":"","url":"https://api.github.com/users/ArnaudValensi","html_url":"https://github.com/ArnaudValensi","followers_url":"https://api.github.com/users/ArnaudValensi/followers","following_url":"https://api.github.com/users/ArnaudValensi/following{/other_user}","gists_url":"https://api.github.com/users/ArnaudValensi/gists{/gist_id}","starred_url":"https://api.github.com/users/ArnaudValensi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArnaudValensi/subscriptions","organizations_url":"https://api.github.com/users/ArnaudValensi/orgs","repos_url":"https://api.github.com/users/ArnaudValensi/repos","events_url":"https://api.github.com/users/ArnaudValensi/events{/privacy}","received_events_url":"https://api.github.com/users/ArnaudValensi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular-translate/angular-translate/labels/FAQ","name":"FAQ","color":"eb6420"},{"url":"https://api.github.com/repos/angular-translate/angular-translate/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-12-09T09:46:40Z","updated_at":"2015-12-13T19:01:39Z","closed_at":"2015-12-13T19:01:39Z","body":"The following example create the error:\r\n```\r\nUncaught Error: Plural Function not found for locale: xx\r\n```\r\n\r\n```javascript\r\nrequire('./node_modules/messageformat/messageformat.js');\r\nrequire('./node_modules/messageformat/locale/fr.js');\r\nrequire('angular-translate-interpolation-messageformat');\r\n\r\n...\r\n\r\n$translateProvider.useMessageFormatInterpolation();\r\n$translateProvider.preferredLanguage('xx');\r\n```\r\n\r\nThe problem is in the load code of `angular-translate-interpolation-messageformat'`:\r\n```javascript\r\n(function (root, factory) {\r\n  if (typeof define === 'function' && define.amd) {\r\n    // AMD. Register as an anonymous module unless amdModuleId is set\r\n    define([\"messageformat\"], function (a0) {\r\n      return (factory(a0));\r\n    });\r\n  } else if (typeof exports === 'object') {\r\n    // Node. Does not work with strict CommonJS, but\r\n    // only CommonJS-like environments that support module.exports,\r\n    // like Node.\r\n    module.exports = factory(require(\"messageformat\"));\r\n  } else {\r\n    factory(MessageFormat);\r\n  }\r\n}(this, function (MessageFormat) {\r\n...\r\n```\r\n\r\nBecause we're using Browserify, `exports` is an object, so the code is loaded with this line:\r\n`module.exports = factory(require(\"messageformat\"));`.\r\nThis line reload the module `messageformat` in the window scope which is replaces our first loading with our locale:\r\n```\r\nrequire('./node_modules/messageformat/messageformat.js');\r\nrequire('./node_modules/messageformat/locale/fr.js');\r\n```\r\n"}}