Skip to content
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

Open
timbrandin opened this issue May 11, 2014 · 11 comments
Open

Translatable path -- Reactive path #656

timbrandin opened this issue May 11, 2014 · 11 comments

Comments

@timbrandin
Copy link

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.

@tmeasday tmeasday added the idea label May 12, 2014
@tmeasday
Copy link
Contributor

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?

@tmeasday tmeasday added this to the Icebox milestone May 12, 2014
@timbrandin
Copy link
Author

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')
...

@tmeasday
Copy link
Contributor

I guess I'm wondering what would happen if it changed during a user's session? What would happen to the existing route?

@timbrandin
Copy link
Author

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.
/logga-in -> /sign-in

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.

@timbrandin
Copy link
Author

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

@martinopic
Copy link

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 /se/login and /en/login. I'd be interested in adding the features you are describing in this ticket.

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

@timbrandin
Copy link
Author

Right! // T

Skickat från min iPhone

13 aug 2014 kl. 10:32 skrev Martino Piccinato notifications@github.com:

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 /se/login and /en/login. I'd be interested in adding the features you are describing in this ticket.

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


Reply to this email directly or view it on GitHub.

@cmather
Copy link
Contributor

cmather commented Aug 13, 2014

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.

On Aug 13, 2014, at 1:32 AM, Martino Piccinato notifications@github.com wrote:

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 /se/login and /en/login. I'd be interested in adding the features you are describing in this ticket.

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


Reply to this email directly or view it on GitHub.

@martinopic
Copy link

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.

@dohomi
Copy link

dohomi commented Aug 15, 2014

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:
https://github.com/EventedMind/iron-router/blob/refactor/notes.txt
Thanks

@martinopic
Copy link

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 /logga-in for the "se" route and /sign-in for the "en" route.

Unfortunately the package just works with 0.9 version of iron-router, next step will be to refactor it for 1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants