Reputation: 22264
I'm trying to determine whether to show the Spanish
or English
button on my web application.
<% if I18n.locale == 'es' %>
<a href="<%= set_english_path %>" class="thin">English</a>
<% else %>
<a href="<%= set_spanish_path %>" class="thin">Spanish</a>
<% end %>
The if
condition always fails and the Spanish button is always displayed.
RubyMine show this upon inspection (during debugging):
So why is the comparison failing?
Upvotes: 11
Views: 8799
Reputation: 4847
You should use symbol instead of string when searching/comparing/setting locale. Try:
<% if I18n.locale == :es %>
Documentation for I18n is there http://guides.rubyonrails.org/i18n.html
Upvotes: 28