{"action":"created","issue":{"url":"https://api.github.com/repos/aurelia/i18n/issues/85","repository_url":"https://api.github.com/repos/aurelia/i18n","labels_url":"https://api.github.com/repos/aurelia/i18n/issues/85/labels{/name}","comments_url":"https://api.github.com/repos/aurelia/i18n/issues/85/comments","events_url":"https://api.github.com/repos/aurelia/i18n/issues/85/events","html_url":"https://github.com/aurelia/i18n/issues/85","id":144226688,"number":85,"title":"Namespace issues","user":{"login":"Souldrinker","id":10742828,"avatar_url":"https://avatars.githubusercontent.com/u/10742828?v=3","gravatar_id":"","url":"https://api.github.com/users/Souldrinker","html_url":"https://github.com/Souldrinker","followers_url":"https://api.github.com/users/Souldrinker/followers","following_url":"https://api.github.com/users/Souldrinker/following{/other_user}","gists_url":"https://api.github.com/users/Souldrinker/gists{/gist_id}","starred_url":"https://api.github.com/users/Souldrinker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Souldrinker/subscriptions","organizations_url":"https://api.github.com/users/Souldrinker/orgs","repos_url":"https://api.github.com/users/Souldrinker/repos","events_url":"https://api.github.com/users/Souldrinker/events{/privacy}","received_events_url":"https://api.github.com/users/Souldrinker/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-03-29T10:49:08Z","updated_at":"2016-03-31T13:37:25Z","closed_at":null,"body":"I've just upgraded to aurelia-i18n 0.5.0 based on i18next v2 and have ran into some issues that I'm not sure if it's bugs, features or just me doing something wrong.\r\n\r\nI changed my plugin setup to look like this (the commented out rows are for test and in earlier versions I only used the default namespace):\r\n```\r\n        .plugin(\"aurelia-i18n\", instance => {\r\n            instance.i18next.use(XHR);\r\n            instance.setup({\r\n                backend: {\r\n                    loadPath: \"locales/{{lng}}/{{ns}}.json\"\r\n                },\r\n                lng: \"en-AU\"\r\n                attributes: [\"t\", \"i18n\"],\r\n                //ns: [\"translation\", \"main\"],\r\n                //defaultNs: \"main\",\r\n                fallbackLng: \"en\",\r\n                debug: false\r\n            });\r\n```\r\n\r\nThe first issue I ran into was that if I set ```lng``` or ```fallbackLng``` to ```en``` the translation.json files never got loaded.\r\n\r\nFrom what I can see that is because you in relativeTime.js set have this line:\r\n```\r\nthis.service.i18next.addResources(key, 'translation', translation);\r\n```\r\n...which then in ```BackendConnector.queueLoad``` exclude the translation.json files to be loaded since hasResourceBundle returns true since the bundle already had been added in code.\r\n\r\nI suppose this is intentional, but this prevents me from using the default translation namespace for my own translations (which wasn't the case in earlier versions).\r\n\r\nI then tried to add the ns setup as suggested in your documentation, but realized that the syntax there where bad and should probably be as I commented out above.\r\n\r\nBut even then the defaultNS seem to be ignored, so if I uncomment the above and add ```main:``` to all my translations stuff seem to work.\r\n\r\nI suppose that is also because you assume your resources already should exist to be able to use the different value converters?\r\n\r\nDoes this mean we always have to add namespace prefixes now with the new version?"},"comment":{"url":"https://api.github.com/repos/aurelia/i18n/issues/comments/203939704","html_url":"https://github.com/aurelia/i18n/issues/85#issuecomment-203939704","issue_url":"https://api.github.com/repos/aurelia/i18n/issues/85","id":203939704,"user":{"login":"johnraz","id":304164,"avatar_url":"https://avatars.githubusercontent.com/u/304164?v=3","gravatar_id":"","url":"https://api.github.com/users/johnraz","html_url":"https://github.com/johnraz","followers_url":"https://api.github.com/users/johnraz/followers","following_url":"https://api.github.com/users/johnraz/following{/other_user}","gists_url":"https://api.github.com/users/johnraz/gists{/gist_id}","starred_url":"https://api.github.com/users/johnraz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnraz/subscriptions","organizations_url":"https://api.github.com/users/johnraz/orgs","repos_url":"https://api.github.com/users/johnraz/repos","events_url":"https://api.github.com/users/johnraz/events{/privacy}","received_events_url":"https://api.github.com/users/johnraz/received_events","type":"User","site_admin":false},"created_at":"2016-03-31T13:37:25Z","updated_at":"2016-03-31T13:37:25Z","body":"I do experience the same issue without bundling.\r\n\r\nThis is quite tricky to reproduce because i18next will load some resources or not depending on your settings.\r\n\r\nYou should be able to reproduce with the following (using XHR backend):\r\n```\r\nlet config = {\r\n  backend: {\r\n    loadPath: '/locales/{{lng}}/{{ns}}.json'\r\n  },\r\n\r\n  attributes: ['t', 'i18n'],\r\n  lng: 'en',\r\n  fallbackLng : 'en',\r\n  debug: true\r\n};\r\n```\r\n\r\nNext try to activate, let's say french and you will get:\r\n\r\n```\r\ni18next: languageChanged fr\r\nlogger.js:25 i18next::translator: missingKey fr translation Username Username\r\nlogger.js:25 i18next::translator: missingKey fr translation Login Login\r\n```\r\n\r\nAnd I don't see any activity in the network panel, no 404 nothing, so it's not an issue with the resource not being available, i18next will simply not try to load the resource at all because it believes it is already loaded as per @Souldrinker's initial analysis.\r\n\r\nAdding this line to the config file and renaming your translation files accordingly fixes it and then everything works as expected.:\r\n```\r\nns: ['translation', 'anotherNs'],\r\n```"}}