Extract Grape::Util::Translation for shared I18n logic#2662
Merged
Conversation
Danger ReportNo issues found. |
70253be to
e82e52e
Compare
7b25994 to
daeec9c
Compare
46be620 to
7119a08
Compare
dblock
approved these changes
Mar 9, 2026
714a735 to
ae49717
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ae49717 to
e0c075d
Compare
ericproulx
added a commit
that referenced
this pull request
Mar 9, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ericproulx
added a commit
that referenced
this pull request
Mar 9, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dblock
approved these changes
Mar 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Isolates all I18n logic into a single
Grape::Util::Translationmodule, eliminating duplicated locale-fallback code and directI18ncalls scattered across exceptions and validators.Changes
Grape::Util::Translation(new module)#translatewrapsI18n.translatewith aMISSINGsentinel to reliably detect absent keys (vs. blank translations):enwhen the current locale has no translation, unlessenforce_available_locales: trueand:enis not in the available locales list**) are forwarded verbatim to I18n as interpolation variablesConsumers
Exceptions::Base— includesTranslation; removes localtranslate,fallback_message, and related constants; Hash message branch uses pattern matching (=>) to destructure{ key:, **opts }Exceptions::Validation—attr_accessor→attr_readerforparamsandmessage_key; params always normalized to Array; Hash message support ({ key:, **opts }) formessage_keyextraction and translationExceptions::ValidationErrors— removesERRORS_FORMAT_KEY/DEFAULT_ERRORS_FORMAT; delegates totranslateValidators::Base— includesTranslation; custom validators inherittranslateautomaticallyLengthValidator/SameAsValidator— replacedformat I18n.t(...)withtranslateSpec — I18n isolation
translation_spec: new spec forGrape::Util::Translationdirectly, includingI18n::ReservedInterpolationKeypropagationcoerce_validator_spec: replacedI18n.load_path <<mutation withstore_translations; usesI18n.with_localeat call sites; no global locale mutationbase_i18n_spec: new spec verifying request-time locale is used regardless of the locale active at definition timebase_spec: all I18n state changes (available_locales,enforce_available_locales) are self-contained viaaround+ensurevalidation_spec: expanded with Hash message (interpolation), Proc message, and String message caseszh-CN.yml: translations stored inline viastore_translationsTest plan
bundle exec rspecbundle exec rspec --seed 16961(order-sensitive check)🤖 Generated with Claude Code