From 5af7bc1aee5511964c135f30905ba454571017de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baz=C3=A1n?= Date: Thu, 3 Sep 2015 23:47:55 +0200 Subject: [PATCH 1/2] removes language switcher if only one locale --- app/views/shared/_locale_switcher.html.erb | 34 ++++++++++++---------- spec/features/localization_spec.rb | 11 +++++++ 2 files changed, 29 insertions(+), 16 deletions(-) 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/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 From cb6949e918eae18266c20e0830004bfe9477e2cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baz=C3=A1n?= Date: Thu, 3 Sep 2015 23:48:25 +0200 Subject: [PATCH 2/2] disables english locale in production (temporary change until texts are ready) --- config/environments/production.rb | 2 ++ 1 file changed, 2 insertions(+) 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