Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 2.42 KB

File metadata and controls

40 lines (30 loc) · 2.42 KB

Internationalization (i18n) Guidelines

This project focuses on ensuring a fully internationalized experience relative to talawa-admin. We employ automated checks to enforce translation compliance, mirroring the robust system used in Talawa Admin.

Checks Overview

The following checks run in CI to maintain translation quality:

1. check-i18n (Hardcoded Text Detection)

  • Purpose: Detects user-visible text that has not been internationalized (hardcoded strings in JSX, attributes, specific function calls).
  • Command: pnpm run check-i18n
  • Fix: Wrap the text in t('key') and add the key to the appropriate locale file (e.g., public/locales/en/razorpay.json).
  • Ignoring False Positives:
    • // i18n-ignore-line: Ignore the current line.
    • // i18n-ignore-next-line: Ignore the next line.

2. compare_translations.py (Translation Completeness)

  • Purpose: Ensures all keys present in the default language (en) are also present in other supported languages.
  • Location: .github/workflows/scripts/compare_translations.py
  • Command: python .github/workflows/scripts/compare_translations.py
  • Fix: Add the missing keys to the target language JSON file.

3. translation_tag_check.py (Key Validation)

  • Purpose: Scans code for t('key') usage and verifies that every used key actually exists in the default locale files.
  • Location: .github/workflows/scripts/translation_tag_check.py
  • Command: python .github/workflows/scripts/translation_tag_check.py --locales-dir public/locales/en --directories src plugins
  • Fix: Add the missing key to the corresponding English locale file (e.g., public/locales/en/plugin-map.json).
  • Note: If using dynamic keys or keys with prefixes not autodetected, you may need to ensure they match the structure or use ignore comments if strictly necessary (though ideally all keys should be valid).

Locales Structure

  • Location: public/locales/{lang}/{namespace}.json
  • Example: public/locales/en/razorpay.json

Workflow

  1. Develop: Write code using t('namespace.key').
  2. Add Keys: Add English translations to public/locales/en/{namespace}.json.
  3. Validate: Run pnpm run check-i18n and the python scripts to verify.
  4. PR: CI will run these checks. check-i18n currently runs in non-blocking mode (warnings only) due to legacy debt, but other checks are strict.