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::JobEntity serializes jobs in bulk, through stage_entity and job_group_entity. Rebuilding the hash would cost 53 lookups and one allocation per failed job to use one string. Marking the values with N_ and translating at lookup costs one lookup, the pattern app/models/application_setting.rb already uses.
  • Why the Job| namespace? It already holds 96 job page strings including full-sentence errors. CiStatusLabel| and CiStatusText| hold single status words.
  • Did any wording change? No. Every value was compared key by key against master and 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.

🛠️ with ❤️ at Siemens

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

  1. Confirm the text is unchanged, and that script_failure still returns nil so 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
  2. Confirm the messages are now extractable:

    grep 'msgid "Job|There is an unknown failure, please try again"' locale/gitlab.pot
  3. 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.

Edited by Gerardo Navarro

Merge request reports

Loading
Loading