-1

I set the default_locale of my rails app to french: config.i18n.default_locale = :fr

Then I installed devise gem. And applied devise to the model Membre.

new.html.erb:

<h2><%= t('login') %></h2>

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
  <div class="field">
    <%= f.label :email %><br />
    <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
  </div>

fr.yml

fr:
  login: "S'indentifer"
  
  activerecord:
    models:
      Membre:
    attributes:
      Membre:
        email: "e-mail"
        password: "mot de passe"

Login gets translated, so the i18n configuration is ok. but email and password remain in English.

thiebo
  • 1,339
  • 1
  • 17
  • 37

1 Answers1

2

Use the downcase model name like below and check the rails guide for more details - https://guides.rubyonrails.org/i18n.html#translations-for-active-record-models

fr:
  login: "S'indentifer"
  
  activerecord:
    models:
      membre:
    attributes:
      membre:
        email: "e-mail"
        password: "mot de passe"
Aarthi
  • 1,451
  • 15
  • 39