I18n locale. format with and without attribute nam

2019-09-02 18:57发布

Here are two approaches to showing AR records

# A: SHOW attribute name
nb: 
  errors:
    format: "%{attribute} %{message}"

# B: HIDE attribute name
nb:
  errors:
    format: "%{message}"

I want B: HIDE for simpleform The message is tied to the input box already, in-context. Why say Name can't be blank on when can't be blank suffice.

Currently we do B: HIDE, as it looks great in UI. But in specs, console and logs we are blind:

There was an error: can't be blank
#NOT HELPFUL, what attribute of what?

With A: SHOW we get

There was an error: Name can't be blank

I want both! Kinda greedy. How can I get what I want? :)


Thought I had: What if I18n lookup context for simpleform had format: as well?

[i18n-debug] en.attributes.report_date => nil
[i18n-debug] nb.errors.format => "%{message}"

alas, no.

If it had en.simpleform.errors.format first, then I could override... There might be other, simpler, ideas out there. Thank you.

0条回答
登录 后发表回答