The Rails i18n guide section 4.1.4 on "lazy" lookups says:
Rails implements a convenient way to look up the locale inside views
(Emphasis theirs, and implying to me, at least, that it is restricted only to views...) However, it seems that this commit to Rails brought "lazy" lookups into controllers as well, with the key being in the form of:
"#{ controller_path.gsub('/', '.') }.#{ action_name }#{ key }"
which in your case should get you users.create.notice
.
So, if you're happy with something like:
# /app/controllers/users_controller.rb
def create
...
redirect_to root_url, notice: t('.notice')
...
end
You should be able to just declare that value in:
# /config/locales/en.yml
en:
users:
create:
notice: "User account was successfully created."
I know this doesn't take you quite all the way of having a default spot where Rails would automatically go and fetch a flash notice on failure to create a user, but it's a bit better than typing out a full i18n key every time.