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.
The following checks run in CI to maintain translation quality:
- 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.
- 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.
- 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).
- Location:
public/locales/{lang}/{namespace}.json - Example:
public/locales/en/razorpay.json
- Develop: Write code using
t('namespace.key'). - Add Keys: Add English translations to
public/locales/en/{namespace}.json. - Validate: Run
pnpm run check-i18nand the python scripts to verify. - PR: CI will run these checks.
check-i18ncurrently runs in non-blocking mode (warnings only) due to legacy debt, but other checks are strict.