Rails engine ActiveRecord models I18n -
i have rails app depends on separate engine (stored in vendor/engine_name). engine has activerecord object bar:
module foo class bar < activerecord::base # has attribute bar_attr end end in engine's config/locales/en.yml file, i've tried:
en: activerecord: attributes: bar_attr: "test" i've tried:
en: activerecord: attributes: bar: bar_attr: "test" and:
en: activerecord: attributes: foo: bar: bar_attr: "test" but no matter what, when call foo::bar.human_attribute_name("bar_attr") parent app, "bar attr" (e.g. default human attribute name). note same problem occurs foo::bar.model_name.human when try translations using:
en: activerecord: models: ... i'm not sure if app/engine structure relevant, i've tried above 3 en.yml formats within parent app's translations file too, no luck.
what missing these model names/attributes translate correctly?
it took bit of searching found answer in question inheriting rails i18n validation error messages in subclass trying i18n working activerecord in rails engine.
based on example above, answer like,
en: activerecord: attributes: foo/bar: bar_attr: "test"
Comments
Post a Comment