我必须使用Devise更新Rails应用程序,以显示尝试登录应用程序时被锁定的剩余分钟数。
在devise.en.yml文件中,我得到:
en:
devise:
confirmations:
confirmed: "Your email address has been successfully confirmed."
send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
failure:
already_authenticated: "You are already signed in."
inactive: "Your account is not activated yet."
invalid: "Invalid %{authentication_keys} or password."
locked: "Your account is locked. Please try again in %{number_of_minutes} minutes"
last_attempt: "You have one more attempt before your account is locked."
not_found_in_database: "Invalid %{authentication_keys} or password."
timeout: "Your session expired. Please sign in again to continue."
unauthenticated: "You need to sign in or sign up before continuing."
我在锁定的:错误消息中有一个名为'number_of_minutes'的变量,但是无论我尝试什么,我都会得到:
missing interpolation argument :number_of_minutes in "Your account is locked. Please try again in %{number_of_minutes} minutes" ({:resource_name=>:user, :authentication_keys=>"E-mail address"} given)
我已将其添加到视图中,覆盖了SessionsController,设置了默认语言环境,尝试了一堆在线建议,但没有运气。
有什么想法吗?
干杯,阿德里安
变量必须作为哈希传递,而不仅仅是一个值。
您认为您应尝试使用::>来翻译
I18n.t 'devise.failure.locked', number_of_minutes: <value>
替换为您需要的变量