-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a simple form to send locale changes
- Loading branch information
Showing
5 changed files
with
42 additions
and
45 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
28 changes: 13 additions & 15 deletions
28
backend/app/views/spree/admin/shared/_locale_selection.html.erb
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 |
---|---|---|
@@ -1,16 +1,14 @@ | ||
<% available_locales = Spree.i18n_available_locales %> | ||
<% if available_locales.size > 1 %> | ||
<label class="admin-navbar-selection admin-locale-selection"> | ||
<i class="fa fa-globe fa-fw" title="<%= I18n.t('spree.choose_dashboard_locale') %>"></i> | ||
<select class="js-locale-selection custom-select fullwidth"> | ||
<%= | ||
options_for_select( | ||
available_locales.map do |locale| | ||
[I18n.t('spree.i18n.this_file_language', locale: locale, default: locale.to_s, fallback: false), locale] | ||
end.sort, | ||
selected: I18n.locale, | ||
) | ||
%> | ||
</select> | ||
</label> | ||
<% available_locale_options_for_select = Spree.i18n_available_locales.map { | ||
[I18n.t('spree.i18n.this_file_language', locale: _1, default: _1.to_s, fallback: false), _1] | ||
}.sort %> | ||
|
||
<% if available_locale_options_for_select.size > 1 %> | ||
<%= form_tag(admin_set_locale_path(format: :html), method: :put, style: "width: 100%;") do %> | ||
<label class="admin-navbar-selection admin-locale-selection"> | ||
<i class="fa fa-globe fa-fw" title="<%= I18n.t('spree.choose_dashboard_locale') %>"></i> | ||
<select class="custom-select fullwidth" onchange="this.form.requestSubmit()"> | ||
<%= options_for_select(available_locale_options_for_select, I18n.locale) %> | ||
</select> | ||
</label> | ||
<% end %> | ||
<% end %> |
17 changes: 17 additions & 0 deletions
17
backend/app/views/spree/admin/shared/_locale_selection_solidus_admin.html.erb
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,17 @@ | ||
<% available_locale_options_for_select = Spree.i18n_available_locales.map { | ||
[I18n.t('spree.i18n.this_file_language', locale: _1, default: _1.to_s, fallback: false), _1] | ||
}.sort %> | ||
|
||
<% if available_locale_options_for_select.size > 1 %> | ||
<li> | ||
<%= form_tag(admin_set_locale_path(format: :html), method: :put, style: "width: 100%;") do %> | ||
<label> | ||
<svg aria-hidden="true"><use xlink:href="<%= image_path('spree/backend/themes/solidus_admin/remixicon.symbol.svg') %>#ri-global-line"></use></svg> | ||
<select name="switch_to_locale" onchange="this.form.requestSubmit()"> | ||
<%= options_for_select(available_locale_options_for_select, selected: I18n.locale) %> | ||
</select> | ||
<svg aria-hidden="true"><use xlink:href="<%= image_path('spree/backend/themes/solidus_admin/remixicon.symbol.svg') %>#ri-expand-up-down-line"></use></svg> | ||
</label> | ||
<% end %> | ||
</li> | ||
<% end %> |
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