-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using errors.add(:key, 'some text') doesn't translate :key in rails 5 #56
Comments
Hmm.. Perhaps this PR fixes it: #35 |
oliverguenther
added a commit
to opf/openproject
that referenced
this issue
Jan 8, 2018
The validator passed to AM::Error does not use the `i18n_scope` we define on either Reform::Form or the model, but is delegated from the included AM::Translations module. This in turn causes I18n to lookup the scope `:activemodel`, failing the localization. trailblazer/reform-rails#56 trailblazer/reform-rails#35
oliverguenther
added a commit
to opf/openproject
that referenced
this issue
Jan 9, 2018
The validator passed to AM::Error does not use the `i18n_scope` we define on either Reform::Form or the model, but is delegated from the included AM::Translations module. This in turn causes I18n to lookup the scope `:activemodel`, failing the localization. trailblazer/reform-rails#56 trailblazer/reform-rails#35 [ci skip]
emaglio
pushed a commit
that referenced
this issue
Nov 16, 2020
* Override reform full_messages to use ActiveModel full_messages Reform has its own full_messages implementation as we can see here https://github.com/trailblazer/reform/blob/master/lib/reform/errors.rb#L29 and reform-rails ResultErrors class inherits from Reform::Contract::Result::Errors, so when you call "full_messages" to get the full error messages, it was calling reform full_messages implementation instead of delegating to ActiveModel and this is a problem for whom need to translate attribute names, because reform only humanizes the attribute name. Fixes: #56 * Fix full_messages to get full_messages of form collections We iterate over each field and for fields which is value is a twin::collection we get the instance variable of @amv_errors and call full_messages which will return the full translated messages of the collection fields. * Fix full_messages por nested property
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Attribute names are no longer translated. I'm not sure where the problem is, wether it is with
reform-rails
,i18n
and/orrails
. Maybe I'm calling the error messages in a wrong way.Example:
In rails 4
:name
was translated to whatever I had defined inactiverecord.en.yml
:I'm getting the error message like this:
Gemfile.lock:
The text was updated successfully, but these errors were encountered: