Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow guest users to select their locale
This commit makes it so that guest users can select their locale from the locale selector as if they were logged in. Moreover, guest users' locale on the site will now be automatically determined based on their browser settings in case they haven't selected one themselves.
- Loading branch information
Showing
3 changed files
with
29 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
%li.dropdown | ||
%a.nav-link.dropdown-toggle{:href => "", :"data-toggle" => "dropdown", :"aria-haspopup" => true, :"aria-expanded" => false} | ||
= image_tag "i18n/#{I18n.locale}.png", :class => "locale-flag" | ||
%ul.dropdown-menu.dropdown-menu-right{:"aria-labelledby" => "dropdown02"} | ||
- I18n.available_locales.each do |l| | ||
- if user_signed_in? | ||
%a.dropdown-item{:"data-turbo" => "true", :"data-turbo-method" => "put", :href => users_locale_path(:locale => l)} | ||
= image_tag "i18n/#{l}.png", :class => "locale-flag" | ||
= SYS::LOCALES_MAP.key(l) | ||
- else | ||
%a.dropdown-item{:href => "?locale=#{l}"} | ||
= image_tag "i18n/#{l}.png", :class => "locale-flag" | ||
= SYS::LOCALES_MAP.key(l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters