diff --git a/frontend/app/assets/javascripts/spree/frontend.js b/frontend/app/assets/javascripts/spree/frontend.js index 4464d609aa5..3e321eb0069 100644 --- a/frontend/app/assets/javascripts/spree/frontend.js +++ b/frontend/app/assets/javascripts/spree/frontend.js @@ -2,3 +2,4 @@ //= require spree/frontend/checkout //= require spree/frontend/product //= require spree/frontend/cart +//= require spree/frontend/locale_selector diff --git a/frontend/app/assets/javascripts/spree/frontend/locale_selector.js b/frontend/app/assets/javascripts/spree/frontend/locale_selector.js new file mode 100644 index 00000000000..fa48d65e0c6 --- /dev/null +++ b/frontend/app/assets/javascripts/spree/frontend/locale_selector.js @@ -0,0 +1,5 @@ +$(function() { + $('#locale_selector select').change(function() { + this.form.submit(); + }); +}); diff --git a/frontend/app/views/spree/shared/_locale_selector.html.erb b/frontend/app/views/spree/shared/_locale_selector.html.erb new file mode 100644 index 00000000000..2f94c895981 --- /dev/null +++ b/frontend/app/views/spree/shared/_locale_selector.html.erb @@ -0,0 +1,25 @@ +<% available_locales = current_store.available_locales %> +<% if available_locales.many? %> +
  • + <%= form_tag spree.select_locale_path, class: 'navbar-form' do %> +
    + + <%= + select_tag( + :switch_to_locale, + 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 + ), + class: 'form-control' + ) + %> + +
    + <% end %> +
  • +<% end %> diff --git a/frontend/app/views/spree/shared/_nav_bar.html.erb b/frontend/app/views/spree/shared/_nav_bar.html.erb index 60dae128e6b..671af64f876 100644 --- a/frontend/app/views/spree/shared/_nav_bar.html.erb +++ b/frontend/app/views/spree/shared/_nav_bar.html.erb @@ -1,5 +1,6 @@