{"action":"created","issue":{"url":"https://api.github.com/repos/gilsdav/ngx-translate-router/issues/16","repository_url":"https://api.github.com/repos/gilsdav/ngx-translate-router","labels_url":"https://api.github.com/repos/gilsdav/ngx-translate-router/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/gilsdav/ngx-translate-router/issues/16/comments","events_url":"https://api.github.com/repos/gilsdav/ngx-translate-router/issues/16/events","html_url":"https://github.com/gilsdav/ngx-translate-router/issues/16","id":478890323,"node_id":"MDU6SXNzdWU0Nzg4OTAzMjM=","number":16,"title":"Open discussion about new use cases","user":{"login":"Nekronik","id":7140454,"node_id":"MDQ6VXNlcjcxNDA0NTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/7140454?v=4","gravatar_id":"","url":"https://api.github.com/users/Nekronik","html_url":"https://github.com/Nekronik","followers_url":"https://api.github.com/users/Nekronik/followers","following_url":"https://api.github.com/users/Nekronik/following{/other_user}","gists_url":"https://api.github.com/users/Nekronik/gists{/gist_id}","starred_url":"https://api.github.com/users/Nekronik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nekronik/subscriptions","organizations_url":"https://api.github.com/users/Nekronik/orgs","repos_url":"https://api.github.com/users/Nekronik/repos","events_url":"https://api.github.com/users/Nekronik/events{/privacy}","received_events_url":"https://api.github.com/users/Nekronik/received_events","type":"User","site_admin":false},"labels":[{"id":983509569,"node_id":"MDU6TGFiZWw5ODM1MDk1Njk=","url":"https://api.github.com/repos/gilsdav/ngx-translate-router/labels/enhancement","name":"enhancement","color":"a2eeef","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2019-08-09T09:27:21Z","updated_at":"2019-08-13T23:01:58Z","closed_at":null,"author_association":"NONE","body":"### Summary\r\n- [x] Go back to previous language after switching language\r\n- [x] Allow localize redirect of a localize-skipped route\r\n- [x] Skip the localization of a segment of the route\r\n- [ ] Matchers need to be localized when switching language\r\n- [ ] Skip translation but add language for one route\r\n\r\n### Intro\r\n\r\nThis is a quite special issue as it aims to open a discussion based on our use cases and our experience with route localization to help make your library an even more powerful solution.\r\n\r\nA year and a half ago we started using `localize-router`. However, after some time using it we found a few use cases that were not covered by the library. Our first intention was to open a pull request to contribute to the library, but at that moment it seemed that the localize-router was far from being maintained as there were a few important and necessary unattained pull-requests. For this reason, we finally incorporated the project into ours and develop solutions for the different use cases we had that were not covered.\r\n\r\nAfter upgrading to Angular 8 with the new lazy loaded routes we found that the absorbed library was not longer working properly neither in client side nor SSR, and furthermore it was not compatible with Ivy.\r\n\r\nWhile we were looking for solutions, we end up finding your forked library. We think that you have done a very good job and it seems that you are actively maintaining it. For this reason, we thought that instead of fixing our own evolution of `localize-router`, it would be much better to share with you our different use cases so we can help to make and even more powerful route localization library and even to share or contribute with the approaches we took to solve them.\r\n\r\n### Use cases\r\n\r\n#### Allow localize redirect of a localize-skipped route\r\nWe found that we needed to redirect some routes to other localized routes. Redirect was working properly, but we had some routes which we didn’t want to localize and we activated the option `skipRouteLocalization`. However, activating this, also skipped the localization of the route which we were redirecting to.\r\n\r\nOur solution was to add a new option in router data `butLocalizeRedirectTo` to localize the `redirectTo` if needed. Having this capability is a **must have for us**.\r\n\r\n#### Matchers need to be localized when switching language (and they may have localized parameters)\r\n\r\nIn some cases, we need to localize a certain part of a matcher, but localize router was not able to translate those matchers when switching languages.\r\n\r\nOur solution was to add some extra info about the matcher in data, which included the parameters and whether or not or how a parameter should be dealt with.\r\n\r\nIn the following example, the matcher has 5 params and the `mapPage` if it is not a number, we need to translate it based on the key we are providing in the config. Having this capability is a **must have for us**.\r\n\r\n```\r\ndata: {\r\n  localizeRouter: {\r\n    matcher: {\r\n      params: ['country', 'state', 'city', 'street', 'mapPage'],\r\n      config: {\r\n        mapPage: {\r\n          condition: 'NOT_NUMBER',\r\n          key: 'MAP'\r\n        }\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n#### Skip the localization of a segment of the route\r\n\r\nIn some cases, we want to avoid the localization of a route segment, so for example, we avoid to accidentally localize a route parameter.\r\n\r\nOur solution was to create a new prefix that we were including at the start of those segments we didn’t want to translate. When when found the `IGNORE_` prefix, instead of translating the key we striped the prefix and left the rest. It is not a requirement, but it would be very **nice to have**.\r\n\r\n#### Go back to previous language after switching language\r\n\r\nWhen the user switches the language and press back in the browser, the route localizer crashes.\r\n\r\nWe didn’t find a good solution to this problem and it is not a really a must have for us, but it would be **nice to find a solution**.\r\n\r\n### Illustrative matchers example\r\n\r\nWe have prepared an illustrative example about the matcher thing in the following repo: \r\nhttps://github.com/Nekronik/angular-vrwvgb\r\n\r\n#### How it works\r\nThere are 2 matchers that lazy load modules\r\n\r\nAll the posible combinations are displayed\r\n\r\nThe combinations are grouped by which module should load\r\n\r\n#### What is happening\r\n\r\nReuse strategy is reusing the loaded module even when the other one should be loaded (reload and it works to prove it is not working)\r\n\r\nWhen the language is changed the route state is lost and erroneous\r\n`/fr/matcher/aaa/bbb/ccc/12345678` -> `/en/matcher/matcher`\r\n\r\nThe map parameter should be translated (it is not possible to test since url state is lost)\r\n\r\n--------\r\n\r\nWe hope this discussion helps to bring your library forward and make it even more useful to more people to become the router localization reference. Count on us! :smiley: "},"comment":{"url":"https://api.github.com/repos/gilsdav/ngx-translate-router/issues/comments/521040969","html_url":"https://github.com/gilsdav/ngx-translate-router/issues/16#issuecomment-521040969","issue_url":"https://api.github.com/repos/gilsdav/ngx-translate-router/issues/16","id":521040969,"node_id":"MDEyOklzc3VlQ29tbWVudDUyMTA0MDk2OQ==","user":{"login":"rafa-as","id":594574,"node_id":"MDQ6VXNlcjU5NDU3NA==","avatar_url":"https://avatars1.githubusercontent.com/u/594574?v=4","gravatar_id":"","url":"https://api.github.com/users/rafa-as","html_url":"https://github.com/rafa-as","followers_url":"https://api.github.com/users/rafa-as/followers","following_url":"https://api.github.com/users/rafa-as/following{/other_user}","gists_url":"https://api.github.com/users/rafa-as/gists{/gist_id}","starred_url":"https://api.github.com/users/rafa-as/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafa-as/subscriptions","organizations_url":"https://api.github.com/users/rafa-as/orgs","repos_url":"https://api.github.com/users/rafa-as/repos","events_url":"https://api.github.com/users/rafa-as/events{/privacy}","received_events_url":"https://api.github.com/users/rafa-as/received_events","type":"User","site_admin":false},"created_at":"2019-08-13T23:01:58Z","updated_at":"2019-08-13T23:01:58Z","author_association":"NONE","body":"> @rafa-as\r\n> There are some ways to reach your goal:\r\n> \r\n> * Do not put translations for these segments on your translation files\r\n> * Using new `escapePrefix` mechanism\r\n> \r\n> Do you think you need an other feature to achieve it ?\r\n\r\nSounds perfect! We test it soon and will give feedback.\r\n\r\nThanks another time @gilsdav "}}
{"actor":{"display_login":"rafa-as"}}