Files
co-lite/openspec/specs/ui-translations/spec.md
T
ngqileandClaude Opus 5.5 2c6a4dc8ce docs: archive whatsapp-inbox, zh-cn-messages, messages-colite-filter and landing-pages
The owner deferred the WhatsApp e2e (add-whatsapp-inbox task 6.3) until the
business account can be linked; the task stays open with a note. Specs are
synced and the new capabilities have their Purpose written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-02 16:58:47 +08:00

13 KiB

ui-translations Specification

Purpose

Back-office labels load from a database message catalog per language, with English built in as the fallback. Staff can correct wording and add Chinese (zh_CN) translations on the Translations and Languages screens without a release.

Requirements

Requirement: The Portal Shows Labels In The Chosen Language

The admin portal SHALL show every label in the language the user picked, read from the back-office message catalog. A label with no text in that language SHALL fall back to its English text, then to the portal's built-in English, and never show blank. The catalog read SHALL need no session, because the sign-in page shows labels too, and it SHALL return label text only.

Scenario: Chinese picked

  • GIVEN the catalog has Chinese text for the label Leads
  • WHEN a signed-in user picks 简体中文
  • THEN the sidebar shows the Chinese text instead of "Leads"

Scenario: A label without Chinese

  • GIVEN a label has English text in the catalog and no Chinese text
  • WHEN a user who picked 简体中文 opens a page with that label
  • THEN the label shows its English text

Scenario: Catalog unavailable

  • WHEN the catalog cannot be read
  • THEN the portal shows the last catalog it loaded, or its built-in English if it has none
  • AND no label is blank

Requirement: A Wording Change Shows On The Next Page Load

The system SHALL keep a catalog version that increases with every saved or imported label and every language change, within the same write. The portal SHALL check the version on each page load and reload the catalog when it has changed, on every portal instance, with no fixed waiting time.

Scenario: A label is edited

  • GIVEN a user sees a label's Chinese text
  • WHEN a translator saves new Chinese text for that label
  • THEN the next page load shows the new text

Scenario: A refused save

  • WHEN a label save or language change is refused
  • THEN the catalog version does not change

Requirement: Supported Languages Are Kept In A Registry

The system SHALL keep the supported languages in a registry, each with a code that matches the catalog's language keys, a label, an enabled flag and an order. It SHALL start with English (en_US) and 简体中文 (zh_CN) enabled, and Bahasa Melayu (ms_MY), 繁體中文 (zh_TW) and Bahasa Indonesia (in_ID) disabled. The language picker SHALL list only enabled languages in their order, before and after sign-in. If the registry cannot be read, the picker SHALL offer English and 简体中文.

Scenario: Picker after rollout

  • WHEN a user opens the language picker
  • THEN it lists English and 简体中文 only

Scenario: A language is enabled

  • WHEN an admin enables Bahasa Melayu on the Languages page
  • THEN the picker lists it on the next page load, with no redeploy

Scenario: Registry unavailable

  • WHEN the language list cannot be read
  • THEN the picker lists English and 简体中文

Requirement: A Language Change Cannot Break The Registry

The system SHALL refuse:

  • a new language whose code already exists;
  • a change of a language's code;
  • switching English off;
  • switching off the last enabled language.

Each refusal SHALL leave the registry unchanged and SHALL reach the user as a named reason, not a generic error.

Scenario: Duplicate code

  • WHEN an admin adds a language with the code zh_CN
  • THEN it is refused and the page says the code already exists

Scenario: English cannot be switched off

  • WHEN the Languages page lists English
  • THEN its switch is disabled and the page says why
  • AND a direct request to disable English is refused

Scenario: Last enabled language

  • GIVEN only one language is enabled
  • WHEN a request disables it
  • THEN it is refused

Requirement: The Languages Page

The portal SHALL provide a Languages page at /locales that lists every language with its code, label, order and an enabled switch. It SHALL let the user add a language and edit a label and order. The code SHALL be editable only when adding. Switching a language off SHALL ask for confirmation first. Refusals SHALL show on the page.

Scenario: Switching a language off asks first

  • WHEN a user switches 简体中文 off
  • THEN a confirmation is shown
  • AND nothing changes unless the user confirms

Scenario: Code read-only when editing

  • WHEN a user edits an existing language
  • THEN its code is shown read-only

Requirement: The Translations Page Lists And Finds Back-Office Labels

The portal SHALL provide a Translations page at /messages listing the back-office labels in pages, each with its code, English text and Chinese text. The search SHALL match the code, the English text or the Chinese text, ignoring case. A "Missing Chinese" filter SHALL list labels whose Chinese text is absent, blank or the same as the English text. Each such label SHALL be marked with a text badge, not colour alone. The page SHALL offer no way to add or delete a label.

Scenario: Search by Chinese wording

  • GIVEN a label whose Chinese text contains "线索"
  • WHEN the user searches "线索"
  • THEN that label is listed

Scenario: Copied English counts as missing

  • GIVEN a label whose English and Chinese text are both "WhatsApp"
  • WHEN the user turns on "Missing Chinese"
  • THEN that label is listed with a badge that says why

Scenario: No add or delete

  • WHEN the Translations page and its row actions are inspected
  • THEN there is no add and no delete action

Requirement: Editing A Translation

Opening a label SHALL show an edit panel with one multi-line field per enabled language and the code read-only. Closing it with unsaved changes SHALL ask before discarding them. The server SHALL refuse a save that changes a label's code, or that creates a label whose code already exists ignoring case. Label text SHALL always be shown as text, never as markup.

Scenario: Unsaved edits

  • WHEN the user changes a field and closes the panel
  • THEN the panel asks before discarding the change

Scenario: Code change refused

  • WHEN a save request changes an existing label's code
  • THEN it is refused and the label is unchanged

Scenario: Markup is shown as text

  • GIVEN a translator saves <b>Leads</b> as a label's Chinese text
  • WHEN a page shows that label
  • THEN the angle brackets show as text and nothing is bold

Requirement: Placeholders Are Kept In Translations

Each non-English text SHALL keep the same placeholders as the English text, in the {name} and {0} forms. When an edit creates a mismatch, the edit panel SHALL name the missing or extra placeholders and block Save. When the label was mismatched before the edit, it SHALL warn without blocking.

Scenario: A new placeholder mismatch blocks Save

  • GIVEN a label whose English is "{n} unread" and Chinese is "{n} 条未读"
  • WHEN the user changes the Chinese to "条未读"
  • THEN the panel names {n} as missing
  • AND Save is disabled

Scenario: An old mismatch only warns

  • GIVEN a label whose English is "{n} unread" and Chinese is "未读"
  • WHEN the user edits the English
  • THEN the panel warns that {n} is missing in Chinese
  • AND Save stays enabled

Requirement: Translations Export

The Translations page SHALL export every back-office label, with the text in every language, as a JSON file download, without leaving the page.

Scenario: Export downloads

  • WHEN the user clicks Export
  • THEN the browser offers a JSON file with every back-office label
  • AND the page stays on /messages

Requirement: Translations Import With A Preview

The Translations page SHALL import a file in the export shape. It SHALL first show a preview that marks each row as an update, matched by code ignoring case and never by an id in the file, or as a new label. It SHALL apply nothing until the user confirms. A file that is not a JSON list SHALL be rejected on the page without sending anything. Each row SHALL be saved on its own, and a summary SHALL show the counts created and updated and name the failed rows.

Scenario: Preview before import

  • WHEN the user picks an export file
  • THEN the page lists every row as an update or a new label
  • AND nothing is saved until the user confirms

Scenario: Matched by code

  • GIVEN a file row with code leads and the id of another label
  • AND the catalog holds the label Leads
  • WHEN the file is imported
  • THEN the Leads label is updated

Scenario: Not a list

  • WHEN the user picks a file that is not a JSON list
  • THEN the page shows an error and sends nothing

Scenario: One bad row

  • WHEN an import has one row that fails and others that succeed
  • THEN the other rows are saved
  • AND the summary names the failed row

Requirement: Access To Translations And Languages

The Translations page SHALL require BO_MESSAGES and the Languages page BO_LOCALES, checked on the server for every list, detail, export and write, with a signed-in admin. Both modules SHALL be granted to no role, so only super admins have them until a super admin grants them. Saves, imports, exports and language changes SHALL be audited.

Scenario: Without the module

  • WHEN a staff user without BO_MESSAGES opens /messages
  • THEN the not-authorised page is shown
  • AND a direct save request is refused

Scenario: A save is audited

  • WHEN a super admin saves a translation
  • THEN the audit log records who saved which label

Requirement: Internal Catalog Writes Need A Token

Inside the system, message and language writes and full listings SHALL need a user token. Only the catalog, its version and the enabled-language list SHALL be readable without one.

Scenario: Internal write without a token

  • WHEN a request without a user token tries to save a message or language inside the system
  • THEN it is refused

Scenario: Catalog read without a token

  • WHEN the sign-in page loads the catalog without a session
  • THEN the catalog is returned

Requirement: Every Back-Office Label Has Chinese

Every back-office label SHALL have Simplified Chinese text with the same placeholders as its English, using one consistent glossary, as a first pass for a native speaker to review. Every new back-office label SHALL ship with its Chinese text.

Scenario: Back office in Chinese

  • WHEN a user picks 简体中文 and opens any back-office page
  • THEN every label on it shows Chinese text

Scenario: A new label without Chinese

  • WHEN a developer adds a back-office label with no Chinese text
  • THEN the portal's tests fail and name the label

Requirement: Loading The Chinese Keeps English Unchanged

Loading the Chinese SHALL replace earlier Chinese for the back-office labels, leave other languages unchanged, and add missing labels with their English. It SHALL reset the English of any label whose old database text differs from the portal's English, so nobody who keeps English sees a change.

Scenario: English unchanged

  • GIVEN the old database English for the sign-in button is "Login"
  • WHEN the Chinese is loaded and a user who keeps English opens the sign-in page
  • THEN the button reads "Log in"

Requirement: Translations Can Be Limited To Co-Lite Labels

The Translations page SHALL offer a "Co-Lite labels only" checkbox, on by default, that limits the list, the search and the "Missing Chinese" filter to the labels in the portal's built-in English list. Codes SHALL match ignoring case. Turning the checkbox off SHALL list every back-office label.

Scenario: Inherited labels hidden by default

  • GIVEN a back-office label "OrderPayment" that is not in the portal's built-in list, and a label "Leads" that is
  • WHEN the user opens the Translations page
  • THEN "Leads" is listed and "OrderPayment" is not
  • AND "Co-Lite labels only" is checked

Scenario: Missing Chinese counts only Co-Lite labels

  • GIVEN every label in the built-in list has Chinese and some inherited labels have none
  • WHEN the user turns on "Missing Chinese" with "Co-Lite labels only" checked
  • THEN no label is listed

Scenario: Every label on request

  • WHEN the user unchecks "Co-Lite labels only"
  • THEN "OrderPayment" is listed too

Requirement: The Co-Lite Code List Comes From The Portal Server

The portal's server SHALL build the Co-Lite code list from its built-in list and SHALL NOT take codes from the browser. mobile-api SHALL refuse with 400 a code list that is not a list of strings or holds more than 5,000 entries. Export and import SHALL keep covering every back-office label.

Scenario: Code list too long

  • WHEN mobile-api receives a search with 5,001 codes
  • THEN it answers 400 and does not call services-system