-
-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support locale in route paths #23
Comments
@Aaike can you take a look at this one? |
FWIW Aaike's original change no longer applies: in aurelia/router@3185d5b @bryanrsmith moved the relevant code to history-browser. I don't think that is the right place to do this though. Perhaps there is a missing router hook that i18n could use so this doesn't have to be done in the routing system itself. |
that's what @bryanrsmith was talking about as well. I'd really like to see a nice integration via hooks so we don't have to spoil the code all over multiple repos |
At first sight it looks like two hooks should suffice:
Another option is to use a import {config} from 'app-configuration';
function addLocaleToPath(route, params) {
r = clone(route); // I am guessing there is a handy utility function for this
r.path = `${config.locale}/${r.path}`;
return r;
} but also more involved things like using translated paths: import {config} from 'app-configuration';
import {I18N} from 'aurelia-i18next';
function translatePath(route, params) {
r = clone(route); // I am guessing there is a handy utility function for this
r.path = I18N.tr(r.path);
return r;
} of course that would require another hook to pre-process routes before attempting to match them, which makes the whole thing way more complicated than 99% or all sites use, so I wouldn't go down that rabbit hole (again - I've done that once many years ago). |
@zewa666 Has there ben any progress on this front? Is there anything I can do to help? |
@zewa666 ping? |
oh sry totally forgot to reply here. |
@wichert it's been a while, but seems there was an important merged tying into this issue. aurelia/router#409 Wonder if you have time to re-validate how that applies to your story? |
@zewa666 It's certainly a related feature that is useful, but does not implement anything this ticket asks for. |
Thats true, its just the part about applying the translation, nothing regarding the hooks. Just wanted to let you know there is at least some progress going on ;) |
This issue is quite old but I need a way to parse the locale from the url (without defining each route several times for all the locales). Is there a solution to this? |
A common way to handle language selection in a site is to use the first component in the URL path to set the locale. Aaike implemented this in aaike/router@83891160c2c116c388517b344ed91d972089a911 with the following rules:
/${locale}<normal route path>
His changes work fine, and we have a site in production that relies on this behaviour. Unfortunately our use of Aaike's router fork means we can not upgrade to a recent Aurelia version.
In hindsight I am not so sure about the magic no-prefix-for-default-locale rule. This feels a bit risky since it will break for paths that happen to match a locale name: for example
/my/settings
could be both "my settings" or "settings in Burmese", and requires you to have a default locale concept which might not be necessary for anything else.The discussion in zewa666/aurelia-i18next#10 also relates to this topic.
The text was updated successfully, but these errors were encountered: