Skip to content

Bilingual Text and Copy

星冉 edited this page Jul 21, 2026 · 1 revision

Bilingual Text and Copy

中文

The project manages Chinese and English in code. User-visible copy is represented by TextPair(chinese, english) under core/i18n/; callers use .get() for the current language and .format() for arguments.

Authoritative code and domains

  • TextPair.kt: bilingual values, language selection, and formatting.
  • CommonTexts, LogTexts, and EventBusTexts: common, logging, and event copy.
  • SessionTexts, SettingsTexts, AdbTexts, RemoteTexts, CodecTexts, ManagementTexts, and DebugTexts: feature-domain copy.
  • LanguageManager: the single source of the active language.

Local, non-reusable copy may remain in a feature-specific text object. Only stable cross-feature copy belongs in core/i18n/.

Usage rules

  • Titles, buttons, form labels, toasts, user-visible errors, and connection progress must provide both languages.
  • Choose the owning feature domain before adding copy; create a new text object only when no existing domain fits.
  • UI, ViewModels, and user-visible runtime messages call .get() or .format() and do not duplicate language branching.
  • Protocol fields, enum names, internal debug keys, commands, and fixed third-party parameters are not translated.
  • Infrastructure may depend on copy for its domain, but not on a specific page title or UI component.

Example:

val title = SessionTexts.EDIT_SESSION.get()
val message = AdbTexts.CONNECTION_FAILED.format(reason)

Add or change flow

  1. Classify the text as user-visible copy, developer diagnostics, or protocol data.
  2. Add or modify the TextPair in the closest owning object.
  3. Supply Chinese and English in the same change, with equivalent placeholders and meaning.
  4. Check plural meaning, punctuation, argument order, and error context.
  5. Search callers to prevent synonymous copy from being duplicated across objects or feature pages.
  6. Run relevant tests and manually inspect critical screens in both languages.

Wiki bilingual rules

  • Every retained developer technical page must have a complete English page with an English filename and a complete Chinese page with a Chinese filename.
  • Chinese and English heading structure and engineering facts must be equivalent; English is not a summary.
  • File names, class names, commands, and configuration keys remain unchanged.
  • When a page is added, merged, split, or deleted, update both languages and their indexes in the same change.

See Documentation Maintenance Conventions for the complete workflow.

Acceptance checklist

  • No new user-visible raw strings.
  • Both languages express the same complete fact.
  • Formatting placeholders match between languages.
  • Copy has a clear owner and no second resource system was introduced.
  • Chinese wiki pages, English counterparts, and indexes are synchronized.

Clone this wiki locally