I'm using standard Rails forms in my view:
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<div><%= f.label :email_label %><br />
<%= f.email_field :email, :autofocus => true, :class => "form-control" %></div>
<div><%= f.label :password_label %><br />
<%= f.password_field :password, :class => "form-control" %></div>
<% if devise_mapping.rememberable? -%>
<div class="checkbox"><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
<% end -%>
<div>
<!--<%= f.submit :class => "btn btn-default" %>-->
<%= f.submit I18n.t("helpers.label.user.sign_in"), :class => "btn btn-default" %>
</div>
<% end %>
Two questions: 1) The API guide docs at http://guides.rubyonrails.org/i18n.html seem pretty out of date. The section on localized views begins with:
Rails 2.3 introduces another convenient localization feature: localized views (templates).
So I'm not sure how much to trust them, and the two other standard locations http://ruby-i18n.org/wiki and https://github.com/svenfuchs/rails-i18n don't really address my issue:
It's a little more complicated because I'm trying to do this in a Devise view. Which means that the form_for is referring to a User model, even thought the controller is a Sessions controller. So User.create which will work if I use the style here: http://apidock.com/rails/ActionView/Helpers/FormBuilder/submit
fr:
helpers:
user:
submit:
create: "Inscription %{model}"
update: "Confirmer les modifications à %{model}"
with out including any text in the submit line
<%= f.submit %>
But this would affect Create User everywhere, and I only really want to customize the New Session Button with the equivalent of Sign In. Se me connecter
So I'm hacking it with
fr-CA:
helpers:
select:
prompt: Veuillez sélectionner
submit:
create: Créer un %{model}
submit: Enregistrer ce %{model}
update: Modifier ce %{model}
sign_in: Se me connecter
sign_up: Inscription
label:
user:
email_label: Courriel
password_label: Mot de passe
remember_me: Mémoriser mes infos
submit: Se me connecter
sign_in: Se me connecter
sign_up: Inscription
And using
<%= f.submit I18n.t("helpers.label.user.sign_in"), :class => "btn btn-default" %>
But this feels wrong, and also not robust, though it certainly enables easier Cucumber testing.
Any recommendations here? And can anyone comment on whether the I18n community for Rails is still active? Or are people using a different solution? I've considering trying to go with SimpleForm gem and it's I18n features.
<%= l f.submit helpers.label.user.sign_in, :class => "btn btn-default" %>
? – Richard Peck