So, I have custom view sessions/new.html.haml
I have a label in my form
= f.label :login
How my en.yml should look like to replace Login with Email or Username
I included gem rails-i18n and tried
en:
login: "Email or Username"
or
en:
devise:
sessions:
new:
login: Email or Username"
But it still doesn't work.
Rails implements a convenient way to look up the locale inside views. When you have the following dictionary.
In locale folder.
locale
en
session
new
en.yml
In en.yml
en:
sessions:
new:
login: "Email or Username"
In new.html.slim:
t.('.login')
This is I18n lazylookup
Here is how you do that.
en:
activerecord:
models:
user: "User"
attributes:
user:
email: "Email"
login: "Email or Username"
password: "Password"
password_confirmation: "Password confirmation"
current_password: "Current password"
remember_me: "Remember me"
And make sure your locale is 'en' not 'en-us'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.