Per-language Caption columns

Summary

  • Lets users edit a file's caption in additional languages by adding new Caption columns from the column header chevron menu (one per language; the picker hides languages already on screen so two visible Caption columns can never share a language).
  • The existing Caption column's language can also be swapped in place from the same menu, and non-English Caption columns can be removed via a "Remove this caption column" entry. The bare English column (description key) stays the canonical column.
  • Each column's choice + count is part of the existing columnState (visible / order / widths), so it persists via Preferences.json across reloads and devices with no new persistence schema. Per-language draft text rides on the new descriptions map in the row draft (added to DRAFT_FIELDS).

Phabricator

  • T426422 — Add per-language Caption columns (multi-lang captions)

What's in here

  • New helper module src/captions.js — curated 24-language catalog, description / description:<lang> key encoding, getCaptionValue / setCaptionValue helpers that hide the legacy single-string field vs. the per-language map.
  • getAllColumns expands the catalog into addressable columns; visibility/order/widths flow through columnState.
  • formatDescription (wikitext) is now language-agnostic — emits one {{<lang>|1=...}} block per non-empty caption language; legacy single-string description is folded in as English when descriptions.en is empty.
  • normalizeHistoryDetailedItem now populates item.descriptions from every language on the M-entity's labels block.
  • DRAFT_FIELDS adds descriptions so per-language drafts persist.
  • The cell editor, copy button, paste mode (with auto-incrementing-suffix behaviour), header label tag (Caption EN / Caption NL / …), column-defaults header popover, fill-blank / overwrite-selected / overwrite-all bulk actions, sort comparator, search haystack, and the missing-description issue check all route through the caption helpers so any caption language is a first-class citizen.
  • Detail panel writes update both description and descriptions.en in a single onUpdate (otherwise stale Dutch / French / … blocks could appear ahead of the new English text in the published wikitext).

Out of scope

  • Pushing captions as SDC labels via wbeditentity.labelsaddStructuredData currently only sends claims; captions still land in the wikitext via the existing formatDescription path. SDC label publish is a separate task.
  • Per-row "this row uses these languages" overrides — every visible column applies to every row (matches every other column).
  • The detail panel only edits English. Per-language captions are edited from the table view.

Test plan

  • Open the column header chevron menu on the Caption column. Verify the new "Change language" and "Add another caption column" sub-menus list the right available languages (English already used, so "Change language" lists only English as the active radio + every other language; "Add another" lists every language except English).
  • "Add another caption column" → Dutch. Verify a new "Caption NL" column appears immediately to the right of "Caption EN". Type a Dutch caption — verify the English caption is unchanged.
  • Reload the page. Verify both columns + their text persist.
  • On the Dutch column header, "Change language" → German. Verify the column re-keys to "Caption DE" and shows the (empty) German caption slot.
  • On the Dutch column header (after re-adding), verify "Remove this caption column" removes the column from the table without affecting the English column.
  • Open a row's wikitext preview. Verify the {{Information}} template's description= field has one {{<lang>|1=…}} block per non-empty language.
  • In the columns modal, verify only visible Caption columns appear (the curated catalogue isn't dumped as 24 separate rows). Toggle a non-English Caption row's Eye off — verify it disappears from the table.
  • In demo mode (no VITE_OAUTH_CLIENT_ID), verify the Captions feature still works on SAMPLE_UPLOADS.

🤖 Generated with Claude Code

Merge request reports

Loading