francesc / rails-translate-routes

MIT License
147 stars 50 forks source link

allow dashes in url segments + no more url segment downcasing #3

Closed cawel closed 12 years ago

cawel commented 12 years ago

Let me know what you think of my changes.

Martin

francesc commented 12 years ago

Hi Martin,

Just had a quick look over it, what's the purpose? I mean, currently you can already have dashes in a translated url, for example:

model: PressRelease controllers: press_releases in routes.rb: resources :press_releases and in routes.yml: press_releases: "press-releases" in english or press_releases: "notas-de-prensa" in spanish

Is that what you tried to achieve? Correct me if I missunderstood it.

cawel commented 12 years ago

The issue I was trying to fix is when you have dashes in the url's with the default locale. For example, if you have a hardcoded route like this one in your "routes.rb":

get 'who-we-are', :to => 'staticPages#who_we_are'

Then your translatable_segment matcher will fail to recognize "who-we-are" as a valid url segment. Specifically, it will wrongly pick "who" as a segment (and not "who-we-are"). As a result, the route "who-we-are" will not be translated.

Let me know your thoughts.

francesc commented 12 years ago

Ok, I see, I'll make some tests of your branch and merge it to the repo as it doesn't break anything and adds some more flexibility for cases like the one you mention. I don't see any reason to not include it. I'll do it probably tomorrow evening. Thanks!

cawel commented 12 years ago

Glad I could help. Thanks!

francesc commented 12 years ago

Already merged your patches, all but the gem version one, I'll make some more commits and update it myself later in a new release ;)

francesc commented 12 years ago

Just released a new version. Doc is also updated and your're listed as contributor. Thanks!