Skip to content

Commit

Permalink
switch locale with turbo morph
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienpoly committed May 5, 2024
1 parent 26dd2df commit eaffc42
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions app/controllers/locales_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class LocalesController < ApplicationController
def update
redirect_back(fallback_location: root_path)
end
end
8 changes: 4 additions & 4 deletions app/views/application/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<%= link_to t("navbar.suggest_talk"),new_talk_path, class: "btn btn-primary hidden lg:flex" %>

<div class="items-center hidden lg:flex gap-1">
<%= link_to "FR", {locale: :fr}, class: class_names("link-neutral": current_locale == :en) %>
<%= button_to "FR", locale_path, id: "locale-fr", params: {locale: :fr}, method: :patch, class: class_names("link-neutral": current_locale == :en) %>
<%= lucide_icon "slash", class: "h-2 w-2" %>
<%= link_to "EN", {locale: :en}, class: class_names("link-neutral": current_locale == :fr) %>
<%= button_to "EN", locale_path, id: "locale-en", params: {locale: :en}, method: :patch, class: class_names("link-neutral": current_locale == :fr) %>
</div>
</div>
<details class="dropdown dropdown-end" data-controller="dropdown" data-action="keydown.esc->dropdown#close">
Expand All @@ -41,9 +41,9 @@
<div class="divider"></div>

<div tabindex="-1" class="items-center flex justify-center flex-row gap-1">
<%= link_to "FR", {locale: :fr}, class: class_names("link-neutral": current_locale == :en), "aria-label": "Site en Français" %>
<%= button_to "FR", locale_path, id: "dropdown-locale-fr", params: {locale: :fr}, method: :patch, class: class_names("link-neutral": current_locale == :en) %>
<%= lucide_icon "slash", class: "fill-black h-2 w-2" %>
<%= link_to "EN", {locale: :en}, class: class_names("link-neutral": current_locale == :fr), "aria-label": "Website in English" %>
<%= button_to "EN", locale_path, id: "dropdown-locale-en", params: {locale: :en}, method: :patch, class: class_names("link-neutral": current_locale == :fr) %>
</div>
</ul>
</details>
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
resources :talks, only: [ :new, :index, :create ]
resource :lineup, only: [ :show ]
resources :sponsors, only: [ :index ]
resource :locale, only: [ :update ]

get "/communique_2022" => redirect("/communiques/thibault_assus_comdamnation", status: 301)

Expand Down

0 comments on commit eaffc42

Please sign in to comment.