I have moment using the momentjs-rails gem, and I have added the Spanish locale in javascripts/moment/es.js
. I use the I18n gem and I'm unable to switch the moment
language when I switch the app's global language.
Adding , moment.locale('es');
makes it show in Spanish, and adding; moment.locale('en');
makes it show in English but it won't change with I18n.
I have tried in application.js.erb
<% if I18n.locale == :es %>
moment.locale('es');
<% end %>
<% if I18n.locale == :en %>
moment.locale('en');
<% end %>
but moment
's language stays as the 'top' option, in this case 'es'.
So with;
<% if I18n.locale == :en %>
moment.locale('en');
<% end %>
<% if I18n.locale == :es %>
moment.locale('es');
<% end %>
the top option is 'en' so it displays in English.
How can I make moment.js language change when I change the language in I18n????
//= require moment //= require moment/es.js
in my application.js file – Rob Hughes