{"action":"created","issue":{"url":"https://api.github.com/repos/robisim74/angular2localization/issues/22","repository_url":"https://api.github.com/repos/robisim74/angular2localization","labels_url":"https://api.github.com/repos/robisim74/angular2localization/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/robisim74/angular2localization/issues/22/comments","events_url":"https://api.github.com/repos/robisim74/angular2localization/issues/22/events","html_url":"https://github.com/robisim74/angular2localization/issues/22","id":176918477,"number":22,"title":"Feature module - add translations instead of overwriting the existing ones","user":{"login":"Etchelon","id":4141889,"avatar_url":"https://avatars.githubusercontent.com/u/4141889?v=3","gravatar_id":"","url":"https://api.github.com/users/Etchelon","html_url":"https://github.com/Etchelon","followers_url":"https://api.github.com/users/Etchelon/followers","following_url":"https://api.github.com/users/Etchelon/following{/other_user}","gists_url":"https://api.github.com/users/Etchelon/gists{/gist_id}","starred_url":"https://api.github.com/users/Etchelon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Etchelon/subscriptions","organizations_url":"https://api.github.com/users/Etchelon/orgs","repos_url":"https://api.github.com/users/Etchelon/repos","events_url":"https://api.github.com/users/Etchelon/events{/privacy}","received_events_url":"https://api.github.com/users/Etchelon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-09-14T14:13:00Z","updated_at":"2016-09-22T11:37:01Z","closed_at":null,"body":"Ciao di nuovo,\r\nI'm playing with your library and I've noticed that addTranslation/translationProvider will overwrite the translationData object in LocalizationService instead of adding the new translations.\r\nMore details:\r\nI have a SharedModule that exports a singleton LocalizationService in the forRoot method (as explained in the angular documentation) because this SharedModule is also imported by my lazy loaded module, which I'll call BModule.\r\nIn the constructor of BModule (and not in the constructor of the main component in BModule, since there's no single entry point but depends on the route!) I wrote this:\r\n`export default class BModule {\r\n\tconstructor(_localizationService: LocalizationService) {\r\n\t\t//_localizationService.translationProvider(\"/app/ehr/resources/\");\r\n\t\t_localizationService.addTranslation(\"it\", {\r\n\t\t\t\"SET_STATUS\": \"Imposta stato a:\"\r\n\t\t});\r\n\t\t_localizationService.updateTranslation();\r\n\t}\r\n}`\r\nand after the addTranslation/translationProvider calls the translationData object is overwritten. I don't want this because I want to keep global translations (generic things like save, cancel, ecc...) in the \"core module\" of my webapp, and load the translations specific for BModule and its components afterwards.\r\nTherefore, coupling this behavior with namespaced keys (see my other Issue) I can write, in the template of a component in the BModule, something like:\r\n`<div>\r\n  <h1>{{ \"BCOMPONENT1.TITLE\" | translate:lang }}</h1>\r\n  <button type=\"button\" class=\"btn btn-success\">{{ CORE.OK | translate:lang }}</button>\r\n  <button type=\"button\" class=\"btn btn-danger\">{{ CORE.CANCEL | translate:lang }}</button>\r\n</div>`\r\n\r\nMemory usage will still be optimized: BModule resources will be loaded ONLY if the user navigates to a proper route, otherwise not!"},"comment":{"url":"https://api.github.com/repos/robisim74/angular2localization/issues/comments/248878918","html_url":"https://github.com/robisim74/angular2localization/issues/22#issuecomment-248878918","issue_url":"https://api.github.com/repos/robisim74/angular2localization/issues/22","id":248878918,"user":{"login":"Etchelon","id":4141889,"avatar_url":"https://avatars.githubusercontent.com/u/4141889?v=3","gravatar_id":"","url":"https://api.github.com/users/Etchelon","html_url":"https://github.com/Etchelon","followers_url":"https://api.github.com/users/Etchelon/followers","following_url":"https://api.github.com/users/Etchelon/following{/other_user}","gists_url":"https://api.github.com/users/Etchelon/gists{/gist_id}","starred_url":"https://api.github.com/users/Etchelon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Etchelon/subscriptions","organizations_url":"https://api.github.com/users/Etchelon/orgs","repos_url":"https://api.github.com/users/Etchelon/repos","events_url":"https://api.github.com/users/Etchelon/events{/privacy}","received_events_url":"https://api.github.com/users/Etchelon/received_events","type":"User","site_admin":false},"created_at":"2016-09-22T11:37:01Z","updated_at":"2016-09-22T11:37:01Z","body":"Ciao Roberto,\r\nthe fix you provided seems good to me. It doesn't really make all resources available everywhere, across all modules, but it's ok, my use case was to reuse the common resources from the core module inside feature modules. Also I won't have more than 2 feature modules open simultaneously, so it doesn't really matter.\r\n\r\nCan you push it to npm?\r\n\r\nThanks,\r\n\r\nAndrea\r\n"}}
{"actor":{"display_login":"Etchelon"}}