Skip to content
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

Raise on missing translations causes issues in Rails 7.1 #920

Closed
1 task done
tagliala opened this issue Oct 8, 2023 · 0 comments · Fixed by #922
Closed
1 task done

Raise on missing translations causes issues in Rails 7.1 #920

tagliala opened this issue Oct 8, 2023 · 0 comments · Fixed by #922
Labels

Comments

@tagliala
Copy link
Contributor

tagliala commented Oct 8, 2023

When config.i18n.raise_on_missing_translations is enabled, Rails 7.1 raises on missing translations also when a translation is not found in a validation error message. This did not happen in 7.0

For some custom validations, like timeliness, client side validations attempts to create a message for "timeliness" error, which is not present.

On Rails 7.0 this did not fail, and the output would have contained a missing translation error

Steps to reproduce*

  1. Add a custom validation without a translation (validates :leave_date, timeliness: { on_or_after: -> { Time.current } })
  2. Open a form with that field

Expected behavior*

Does not fail

Actual behavior*

*** I18n::MissingTranslationData Exception: Translation missing. Options considered were:
- it-IT.activerecord.errors.models.itinerary.attributes.leave_date.timeliness
- it-IT.activerecord.errors.models.itinerary.timeliness
- it-IT.activerecord.errors.messages.timeliness
- it-IT.errors.attributes.leave_date.timeliness
- it-IT.errors.messages.timeliness

System configuration*

Rails version: 7.1

Ruby version: 3.2.2

Client Side Validations version: main

Code snippet from your model of the validations*

  validates :leave_date, timeliness: { on_or_after: -> { Time.current } }

The whole form code from your template*

  = f.input :leave_date, as: :datetime, default: default_leave_date, start_year: Time.current.year, end_year: 1.year.from_now.year, minute_step: 10, ampm: t('time.ampm'), input_html: { class: 'date-time' }, wrapper: :horizontal_form

The resulting HTML*

not needed

Browser's development console output*

  • I confirm that my browser's development console output does not contain errors

Additional JavaScript Libraries*

does not apply

Repository demostrating the issue

https://github.com/diowa/icare/tree/feature/rails-71

@tagliala tagliala added the bug label Oct 8, 2023
tagliala added a commit that referenced this issue Oct 8, 2023
When `config.i18n.raise_on_missing_translations` is enabled, Rails 7.1
raises on missing translation error when validation messages are not
translated, which is a new behavior causing CSV to fail

For unsupported validations, like `comparison`, and custom validations,
like `timeliness`, CSV attempts to create a message for a key that
is not present.

This commit standardizes the behavior and fallbacks on "invalid" when
a translation is not found, which is supposed to be the desired
behavior for this use case

Close #920
tagliala added a commit that referenced this issue Oct 8, 2023
When `config.i18n.raise_on_missing_translations` is enabled, Rails 7.1
raises on missing translation error when validation messages are not
translated, which is a new behavior causing CSV to fail

For unsupported validations, like `comparison`, and custom validations,
like `timeliness`, CSV attempts to create a message for a key that
is not present.

This commit standardizes the behavior and fallbacks on "invalid" when
a translation is not found, which is supposed to be the desired
behavior for this use case

Close #920
tagliala added a commit that referenced this issue Oct 8, 2023
When `config.i18n.raise_on_missing_translations` is enabled, Rails 7.1
raises on missing translation error when validation messages are not
translated, which is a new behavior causing CSV to fail

For unsupported validations, like `comparison`, and custom validations,
like `timeliness`, CSV attempts to create a message for a key that
is not present.

This commit standardizes the behavior and fallbacks on "invalid" when
a translation is not found, which is supposed to be the desired
behavior for this use case

Close #920
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant