diff --git a/app/views/shared/_locale_switcher.html.erb b/app/views/shared/_locale_switcher.html.erb index c95ad58a1..24165f2af 100644 --- a/app/views/shared/_locale_switcher.html.erb +++ b/app/views/shared/_locale_switcher.html.erb @@ -1,16 +1,18 @@ -
- - - <%= t("layouts.header.locale") %> - -
- -
-
+<% if I18n.available_locales.size > 1 %> +
+ + + <%= t("layouts.header.locale") %> + +
+ +
+
+<% end %> diff --git a/config/environments/production.rb b/config/environments/production.rb index 941ac300e..5e4698336 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -78,4 +78,6 @@ Rails.application.configure do # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + + config.i18n.available_locales = [:es] end diff --git a/spec/features/localization_spec.rb b/spec/features/localization_spec.rb index 974753eb3..0066efbbd 100644 --- a/spec/features/localization_spec.rb +++ b/spec/features/localization_spec.rb @@ -32,4 +32,15 @@ feature 'Localization' do expect(page).to_not have_content('Language') expect(page).to have_select('locale-switcher', selected: 'EspaƱol') end + + scenario 'Locale switcher not present if only one locale' do + initial_locales = I18n.available_locales + I18n.available_locales = [:en] + + visit '/' + expect(page).to_not have_content('Language') + expect(page).to_not have_css('div.locale') + + I18n.available_locales = initial_locales + end end