-
Notifications
You must be signed in to change notification settings - Fork 414
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
Translatable path -- Reactive path #656
Comments
Hey @timbrandin - I'm trying to understand how that might work. Can you provide a more concrete explanation of how the API for this could work? |
This would work for accounts-entry. @route "entrySignIn",
path: ->
T9n.get('signInPath')
... Then one could specify the translated path in the T9n translation files. I don't know if T9n is reactive, but for the simplest use case it would be great if it grabbed the language set in T9n.defaultLanguage after startup. Otherwise I would expect it to work with something like this: @route "entrySignIn",
path: ->
T9n.defaultLanguage = Session.get('defaultLanguage')
T9n.get('signInPath')
... |
I guess I'm wondering what would happen if it changed during a user's session? What would happen to the existing route? |
My expectation is that it would just change the path, As for the case with accounts-entry it would just be the same page but everything is now in another language, handled by the same functions. For example switching from Swedish to English should just change the path for now. To make it simple: It could be a way of using the same route for multiple paths with more than just the URL or URL-pattern to distinguish the route. |
Another use case would be setting the language depending on the alias if the Session variable was not set, but if the language was changed with by the user (through a Session variable) we should change the alias instead. Something like this: @route "node",
path: ->
@entity = Alias.findOne path: @path
@alias = Alias.findOne entityId: @entity.entityId, language: Session.get('currentLanguage')
return @alias.path
data: ->
T9n.currentLanguage = @alias.language
return Entities.find _id: @alias.entityId |
Hi, not exactly the functionality you are looking for but I provide something similar with http://atmospherejs.com/package/iron-router-i18n The package is still rough and immature (0.1.0) but basically working (supporting just lang code prefixed path so in your case would be I think separate package as iron-router-i18n (if possibile) is better as i18n is not something everybody may want with default iron-router (we love modularity right? :-) ). See also the discussion mentioned here: #316 |
Right! // T Skickat från min iPhone
|
Cool! This seems like it would be a great feature. Looking forward to taking a look a this package. Have you taken a look at the work on refactor branch? Also look at Iron.Location (the iron-location project which the new upcoming iron router uses) I wonder if we could implement something there. Let me know if you have trouble setting up the refactor branch.
|
That's very interesting, I was unaware of this refactor. I'll try to have a look but first I'd like to come out with a (very basic but reasonably working) release of iron-router-i18n based on current release. |
Hi, I am currently checking out some ways how to solve my multi-lang trouble. @cmather how would I need to start with the refactor branch? I couldn't find any information inside of the notes document: |
Hi just wanted to update this ticket as I've added to the package martino:iron-router-i18n (https://atmospherejs.com/martino/iron-router-i18n) the feature originally requested by this ticket. It is now possible to have Unfortunately the package just works with 0.9 version of iron-router, next step will be to refactor it for 1.0. |
Hey, it would be really sweet if we could add the feature of having translatable paths.
For example if the setting "path:" optionally could be a function like the template helpers can get reactive if they have Deps within, then we could redirect users depending on the chosen language and get the nice translated paths automagically.
Another use cases is having path aliases coming from a Collection or anything Reactive actually.
The text was updated successfully, but these errors were encountered: