[CLEAN] Synthetic Benchmark PR #36023 - FIX: translation missing when using optional_* placeholder in body #11
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.
User description
Benchmark PR discourse#36023
Type: Clean (correct implementation)
Original PR Title: FIX: translation missing when using optional_* placeholder in body
Original PR Description: All the "optional_*" placeholders are meant to be used in the subject but if you were to use them in the body template you would get a "translation missing" error.
This commit ensures these optional placeholders are also provided when i18ning the body even though they don't make a lot of sense.
Internal ref - t/150916
Original PR URL: discourse#36023
PR Type
Bug fix, Enhancement
Description
Fix translation missing errors when using optional_* placeholders in email body templates
Extract category and tags formatting into reusable helper methods
Provide optional_* placeholders to body template i18n calls
Add comprehensive test coverage for optional placeholders in body templates
Refactor subject method for improved code clarity and maintainability
Diagram Walkthrough
File Walkthrough
message_builder.rb
Add optional placeholders to body template i18nlib/email/message_builder.rb
format_categoryandformat_tagsinto dedicated helper methodsto eliminate code duplication
subjectmethod to improve readability by extractinghas_overridevariableoptional_re,optional_pm,optional_cat,optional_tags) to body template i18n call to preventtranslation missing errors
bodymethod using inlineconditional
message_builder_spec.rb
Update body template test expectationsspec/lib/email/message_builder_spec.rb
body template i18n call
optional_re,optional_pm,optional_cat, andoptional_tagsare passed with empty string defaults
user_notifications_spec.rb
Add comprehensive optional placeholders body testspec/mailers/user_notifications_spec.rb
optional_* placeholders render correctly in body templates
placeholders are properly substituted with actual values
placeholders in custom body templates