Merge pull request #350 from AyuntamientoMadrid/locales
Removes language switcher if only one locale
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<div class="locale">
|
<% if I18n.available_locales.size > 1 %>
|
||||||
|
<div class="locale">
|
||||||
<span class="inline-block">
|
<span class="inline-block">
|
||||||
<i class="icon-language"></i>
|
<i class="icon-language"></i>
|
||||||
<%= t("layouts.header.locale") %>
|
<%= t("layouts.header.locale") %>
|
||||||
@@ -6,11 +7,12 @@
|
|||||||
<form class="locale-form">
|
<form class="locale-form">
|
||||||
<select class="js-location-changer locale-switcher" name="locale-switcher">
|
<select class="js-location-changer locale-switcher" name="locale-switcher">
|
||||||
<% I18n.available_locales.map do |loc| %>
|
<% I18n.available_locales.map do |loc| %>
|
||||||
<option <%= 'selected' if loc == I18n.locale %>
|
<option <%= "selected" if loc == I18n.locale %>
|
||||||
value='<%= current_path_with_query_params(locale: loc) %>'>
|
value="<%= current_path_with_query_params(locale: loc) %>">
|
||||||
<%= I18n.t('locale', locale: loc) %>
|
<%= I18n.t("locale", locale: loc) %>
|
||||||
</option>
|
</option>
|
||||||
<% end %>
|
<% end %>
|
||||||
</select>
|
</select>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|||||||
@@ -78,4 +78,6 @@ Rails.application.configure do
|
|||||||
|
|
||||||
# Do not dump schema after migrations.
|
# Do not dump schema after migrations.
|
||||||
config.active_record.dump_schema_after_migration = false
|
config.active_record.dump_schema_after_migration = false
|
||||||
|
|
||||||
|
config.i18n.available_locales = [:es]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,4 +32,15 @@ feature 'Localization' do
|
|||||||
expect(page).to_not have_content('Language')
|
expect(page).to_not have_content('Language')
|
||||||
expect(page).to have_select('locale-switcher', selected: 'Español')
|
expect(page).to have_select('locale-switcher', selected: 'Español')
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user