Skip to content

docs(i18n): contributor guide for adding new languages #384

Closed

Description

@khaira777

Refs: #372
Depends on: #383

Context

Following the migration to a Git-native use-intl architecture, adding a new language to FloCafe is a simple, structured process. This issue creates a complete contributor guide documenting how translators and developers can contribute translations, add new languages, and handle RTL layouts natively via Git and GitHub pull requests.

What to Document

Create a comprehensive guide at docs/i18n.md and link to it from CONTRIBUTING.md and README.md.

1. For Translators (Editing / Improving Existing Languages)

  • How to fork the repository, locate the relevant message file in frontend/src/lib/i18n/messages/<lang>.json, and edit values.
  • What must NOT be translated:
    • JSON keys and namespace identifiers
    • ICU placeholder variable names (e.g. {count}, {time}, {price})
    • HTML/rich-text tag names where used (e.g. <bold>, <link>, <ltr>)
  • Explanation of ICU MessageFormat syntax (plurals, select statements) to prevent broken formatting strings.
  • How to run local validation (npm run i18n:check) and submit a Pull Request.

2. For Developers (Adding a New Language)

Step-by-step workflow:

  1. Create message file: Copy frontend/src/lib/i18n/messages/en.json to frontend/src/lib/i18n/messages/<lang>.json. (Or run npm run i18n:add -- <lang> if available).
  2. Register language: Add an entry in frontend/src/lib/i18n/languages.ts specifying locale, nativeName, direction ('ltr' | 'rtl'), selectable, and chunk load() function.
  3. Translate values: Translate strings while maintaining 100% key and variable parity with en.json.
  4. Validate: Run npm run i18n:check to verify leaf parity, ICU syntax, parameter matching, and tag parity.
  5. Test in UI: Verify rendering in both desktop and standalone modes.
  6. Submit PR: Open a standard GitHub PR.

3. RTL Language Support Guidelines

  • Setting direction: 'rtl' in languages.ts.
  • How HtmlLangSync automatically manages <html dir="rtl"> in sync with active loaded locale.
  • Using <Ltr> islands for naturally-LTR content (emails, URLs, phone numbers, bill IDs, timestamps).
  • Using .rtl-flip CSS class for mirroring directional icons (arrows, chevrons).
  • Running existing RTL test suites (npm run test:rtl-foundation, npm run test:rtl-setup-auth-settings, etc.).

4. Language Enablement vs. Strict Repository Completeness

  • Explain that all committed language files in the repository must maintain strict 100% key parity with en.json.
  • Explain how a language can exist and function technically in the repository while remaining hidden from end users (selectable: false).
  • Reference Persian (feat(i18n): add Persian/Farsi and Iran support #241) as the standard example of an in-progress language undergoing staged UI/UX acceptance.

5. Architectural Overview

  • Flow: Git message files -> Language Registry (languages.ts) -> Active Locale Loader (loader.ts) -> use-intl -> React UI / createTranslator.
  • Offline-first architecture (zero external translation network dependencies).
  • Typed domain enum mappings (enums.ts).
  • Standalone KDS and Server App language synchronization (server-language.ts).

6. Separation of UI Languages vs. Country/Tax Profiles

  • Explicitly clarify that adding a UI language is separate from configuring country tax packs, currencies, and dialing codes in main/countries.ts. Link to country documentation without conflating the two workflows.

What NOT to do

  • Do NOT reference Crowdin, Weblate, or any external SaaS platform.
  • Do NOT suggest editing core application components when adding a language.
  • Do NOT conflate UI language translation with tax pack or country profile creation.

Acceptance Criteria

  • docs/i18n.md created with clear, actionable guidelines for translators and developers.
  • Discoverable link added in CONTRIBUTING.md.
  • Workflow accurately reflects the Git-native use-intl architecture.
  • RTL guidelines, strict key parity invariant, and language selectability (selectable: false) clearly explained.

Verification

  • Verify that all file links and code examples in docs/i18n.md match the current codebase.
  • Verify that following the documented steps successfully adds a test locale that passes npm run i18n:check.

Activity

  1. added
    documentation
    area:frontend
    on Aug 17, 2026
  2. self-assigned this
    on Aug 19, 2026
  3. khaira777 commented on Aug 19, 2026

    @khaira777
    ContributorAuthor

    Completed by #413 (merged into main at commit 7e648ed). Created comprehensive internationalization and translation contributor guide at docs/i18n.md, added links in docs/README.md, CONTRIBUTING.md, and README.md, and verified all relative markdown paths and code examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:frontenddocumentation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions