Skip to content

Conversation

@CuddlyBunion341
Copy link
Contributor

@CuddlyBunion341 CuddlyBunion341 commented Dec 5, 2025

In ShapeHub, we encountered an issue where a model label wasn't translated, and our tests failed to address this. Relying on the model's human-readable attribute is prone to errors. I believe translations should be explicitly defined.

Rails 8 Introduced the following:

config.i18n.raise_on_missing_translations
Determines whether an error should be raised for missing translations. If true, views and controllers raise I18n::MissingTranslationData. If :strict, models also raise the error. This defaults to false

With config.i18n.raise_on_missing_translations = true:

shapehub(dev)> Croms::Patient.human_attribute_name(:consent)
=> "Consent"

With config.i18n.raise_on_missing_translations = :strict:

shapehub(dev)> Croms::Patient.human_attribute_name(:consent)
(shapehub):1:in '<main>': Translation missing. Options considered were: (I18n::MissingTranslationData)
- en.activerecord.attributes.croms/patient.consent
- en.attributes.consent

        raise exception.respond_to?(:to_exception) ? exception.to_exception : exception
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@CuddlyBunion341 CuddlyBunion341 self-assigned this Dec 5, 2025
@CuddlyBunion341
Copy link
Contributor Author

Ignore md-book. It has been failing for quite some time.

@sislr
Copy link
Member

sislr commented Dec 5, 2025

Ignore md-book. It has been failing for quite some time.

do we still need it? content is now outdated since CD fails, right? I'd get rid of it

@rnestler
Copy link
Member

rnestler commented Dec 5, 2025

Ignore md-book. It has been failing for quite some time.

Fix it, not ignore it!

@rnestler
Copy link
Member

rnestler commented Dec 5, 2025

Fixed it for you: #430

Copy link
Member

@rnestler rnestler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For English applications it may be overkill and the fallbacks would work fine, but since most of our apps are German or multilingual I think it's a good default.

@rnestler rnestler force-pushed the feature/strict-missing-translations branch from 101aef7 to 3b9734c Compare December 5, 2025 14:59
@rnestler rnestler merged commit c26931e into main Dec 5, 2025
2 checks passed
@rnestler rnestler deleted the feature/strict-missing-translations branch December 5, 2025 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants