Worlds: language switch
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled

This commit is contained in:
sto
2026-09-06 16:34:21 +02:00
parent 699e1eb3de
commit 0912a9f408
7 changed files with 40 additions and 28 deletions

View File

@@ -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