kwi / i18n_routing

I18n routing module for Rails 2.3.x and Rails 3. Translate your routes with ease !
MIT License
228 stars 48 forks source link

Rails 3, default language slovenian, nested route, works sometimes #9

Closed Krule closed 14 years ago

Krule commented 14 years ago

This is a weird one, translated routes work (when I look at rake routes), however in case I start server they fail to translate. Then, when I edit the gemfile while server is on, routes start working. If I restart it again they stop until gemfile is edited.

My route looks like:

localized do
  resources :nepremicnines do
    collection do
      get :obcino
    end
  end
end

And en.yml:

en:
  resources:
    nepremicnines: "real_estates"
  path_names:
    obcino: "municipality"

Since my production is on Heroku, with it's read-only fs, this is a bit of a problem for me.

kwi commented 14 years ago

Hum, That's very weird ! So you are using Rails3 ? Wich beta ? And did you test is in production ?

Krule commented 14 years ago

beta4, and yes, tested in production

kwi commented 14 years ago

Do you change the I18n.load_path somewhere And can u try to test if the translations are loaded ?

Krule commented 14 years ago

Translation are loaded for the rest of the application. Load path is not changed, only config.i18n.default_locale.

kwi commented 14 years ago

Hum, right now I have no clue, did you get this thing work since last time ? This could be interesting to know ! Maybe this come from something related to heroku ?

Krule commented 14 years ago

I have figured it out. It loaded on development because after touching routes.rb, they were reloaded after I18n has been initialized. Otherwise routes were initialized before I18n so they had no idea what translations to use.

After I have changed the above code to:

localized('en', :verbose => true) do
  resources :nepremicnines do
    collection do
      get :obcino
    end
  end
end

everything started working.

For a very short while I had:

%x[touch #{RAILS_ROOT}/config/routes.rb]

In my ApplicationController.set_locale, but that was not a real solution.

I think this one can be closed. The only thing left for me is to figure out how to link to same page on different language now.

kwi commented 14 years ago

Ah, glad to know everything finally went well ! I will probably add your solution in the wiki.

For your links to the same page in different language, you just need to change the locale just before creating the link, I think ?

Thanks Krule.

wacaw commented 14 years ago

i've got the same problem.

Is this solution correct? %x[touch #{RAILS_ROOT}/config/routes.rb]

I think that such a solution is only temporary. need to find appropriate

Krule commented 14 years ago

That solution worked for a while. Later on I used https://github.com/kwi/i18n_routing/issues/issue/9/#issue/9/comment/325092 solution and it worked for a while. All of this was actual for Rails 3.0.0.beta4.

Later on I had some issues, but all of them got resolved after Rails 3.0. final was out.

kwi commented 14 years ago

So, It's just you need to pass the locales to localized right? I may put an alert if there is no locale found during the load, it might help !

Krule commented 14 years ago

@kwi I am not sure what exact problem is with @wacaw's app. For me everything started working perfectly with no hacks after 3.0. was out and your first release after that.

kwi commented 14 years ago

Ok, looks great so :) Thanks !