Refactor job callout failure messages to be translatable
What does this MR do and why?
Refactors the job page failure callout so its messages can be translated. Nothing visible changes: every message renders exactly as it does today.
Problem
Currently on master, a user on a non-English locale reads the job page failure
callout in English, whatever locale they picked. Its 53 messages sit as English
literals in a
frozen constant,
so none of them reach locale/gitlab.pot and no translator ever sees them.
Ci::JobEntity serializes the message
and the job page renders it as it arrives, so the frontend does not translate it
either.
Review notes
- Why keep the constant instead of the class method the i18n guide asks for?
Ci::JobEntityserializes jobs in bulk, throughstage_entityandjob_group_entity. Rebuilding the hash would cost 53 lookups and one allocation per failed job to use one string. Marking the values withN_and translating at lookup costs one lookup, the patternapp/models/application_setting.rbalready uses. - Why the
Job|namespace? It already holds 96 job page strings including full-sentence errors.CiStatusLabel|andCiStatusText|hold single status words. - Did any wording change? No. Every value was compared key by key against
masterand came out the same. - What is left alone?
Gitlab::Ci::Status::Build::Failed::REASONS, the status tooltip half, which gets its own merge request so this one stays reviewable.
References
Screenshots or screen recordings
Nothing visual changes. s_ strips the Job| prefix while no translation
exists, so every message renders as it does today.
How to set up and validate locally
-
Confirm the text is unchanged, and that
script_failurestill returnsnilso the serializer keeps skipping it:CommitStatusPresenter.new(Ci::Build.new(failure_reason: :unknown_failure)).callout_failure_message # => "There is an unknown failure, please try again" CommitStatusPresenter.new(Ci::Build.new(failure_reason: :script_failure)).callout_failure_message # => nil -
Confirm the messages are now extractable:
grep 'msgid "Job|There is an unknown failure, please try again"' locale/gitlab.pot -
Open any failed job page and check the callout reads as before.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.