0

I'm using i18n with given params and not session variable. when im posting my info from a certain form and redirecting to another page, it seems to ignore the:

before_filter :set_locale
def set_locale
    I18n.locale = params[:lang] if params.include?('lang')
end

function that is in application controller and i get the requested page with "NO KEY" instead of the dictionary string, only after refreshing the page the keys are loading well.

def save
    @category = Category.find(params[:cat])
    @category.pools.create(:num_of_players => params[:num_players], ...
    :close => close, :badge => badge)
    redirect_to ("/pool/game?ids=2&lang=sp")
end
Meschiany
  • 205
  • 2
  • 16
  • Try changing your line to `I18n.locale = params[:lang] || I18n.default_locale`. – Paul Fioravanti Apr 06 '13 at 11:36
  • is there a proper routes path for your '/pool/game"? try to rake routes, found the routes and use something like pool_game_path(lang: 'sp') instead – Nich Apr 06 '13 at 11:46
  • thank you Paul, but i want to keep the language as it was before the save. Nich, when im refreshing the page after redirecting it works perfectly. it is probably something with not calling the set_locale when redirecting – Meschiany Apr 06 '13 at 11:57
  • If you want to keep the language as it was before the save, would it help then to just change the line again to `I18n.locale = params[:lang] || I18n.current_locale || I18n.default_locale`, assuming the `current_locale` has been set? – Paul Fioravanti Apr 06 '13 at 13:21

0 Answers0