Worlds: language switch
This commit is contained in:
@@ -1,16 +1,22 @@
|
||||
class WorldsController < ApplicationController
|
||||
allow_unauthenticated_access
|
||||
|
||||
before_action :set_w_lang
|
||||
before_action :set_title
|
||||
before_action :set_fr_lang
|
||||
|
||||
def set_title
|
||||
@title = I18n.t("worlds.title")
|
||||
@nonav = true
|
||||
end
|
||||
|
||||
def set_fr_lang
|
||||
I18n.locale = "fr"
|
||||
def set_w_lang
|
||||
if params.has_key?(:lang) && params[:lang] == "en"
|
||||
I18n.locale = "en"
|
||||
@lang = "en"
|
||||
else
|
||||
I18n.locale = "fr"
|
||||
@lang = "fr"
|
||||
end
|
||||
end
|
||||
|
||||
def main
|
||||
@@ -90,7 +96,7 @@ class WorldsController < ApplicationController
|
||||
end
|
||||
|
||||
if w_set.length == 10 && f_set.length == 10 && @world_bet.save
|
||||
redirect_to "/wjpc_bets/main", notice: t("worlds.new.notice")
|
||||
redirect_to "/wjpc_bets/#{@lang}/main", notice: t("worlds.new.notice")
|
||||
else
|
||||
@world_participants = WorldParticipant.all.sort_by { |p| p.name }
|
||||
france = WorldCountry.where(code: "FR").first
|
||||
@@ -117,9 +123,9 @@ class WorldsController < ApplicationController
|
||||
b.save
|
||||
end
|
||||
end
|
||||
redirect_back(fallback_location: root_path, notice: t("worlds.collab.notice"))
|
||||
redirect_back(fallback_location: "/wjpc_bets/#{@lang}/main", notice: t("worlds.collab.notice"))
|
||||
else
|
||||
redirect_to "/wjpc_bets/collab", notice: t("worlds.collab.error")
|
||||
redirect_to "/wjpc_bets/#{@lang}/collab", notice: t("worlds.collab.error")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user