Improve Translation Coverage, Localization Tests, and Documentation for i18n
Improve i18n Reliability, Translation Coverage, and Documentation
This pull request introduces a set of enhancements aimed at improving internationalization (i18n) support across the project. The updates focus on localization testing, translation accuracy, and developer documentation to ensure a more stable and user-friendly multilingual experience.
Summary of Changes
1. Improved Localization Reliability
The i18n/l10n test suite has been refactored to enhance maintainability and catch common localization issues early in development.
Notable improvements:
-
Translation Coverage Validation: Tests now ensure all message keys exist across all
.pofiles, and every language declared in constants has a corresponding translation file. This prevents missing translations in production. -
Localized Error Message Tests: Extended coverage to include translated error messages, including edge cases like invalid API settings (
ALGORITHM) and token validation errors. - Developer-Friendly Debugging: Leveraged subtests to surface multiple translation failures in a single test run, improving development efficiency.
- Test Isolation: Tests that modify global or runtime settings are now isolated to prevent side effects and order-dependent failures.
2. Translation Improvements
-
French (
fr):- Fixed capitalization for the translation of "user" to match the
.pofile (Utilisateur).
- Fixed capitalization for the translation of "user" to match the
-
Chilean Spanish (
es_CL):- Fixed capitalization for the translation of "user" to match the
.pofile (Usuario).
- Fixed capitalization for the translation of "user" to match the
-
Persian (
fa,fa_IR):- Refined translations for clarity and consistency, especially in error messages and algorithm-related terms.
-
Dutch (
nl_NL):- Fixed a typo in the translation for "Unrecognized algorithm type".
3. Test Dependency Update
- Added
polibtosetup.pytest dependencies to enable.pofile parsing in tests and CI environments.
4. Documentation Updates
- Improved documentation with clear instructions on enabling translation support via
LOCALE_PATHS.
Impact
- Developers gain a more dependable localization testing framework.
- Translators benefit from more consistent and accurate source strings.
- Users enjoy clearer, localized error messages and improved setup documentation for enabling translations.
Note:
This PR also ensures that the test suite and translation files are in sync, preventing false negatives in CI and making it easier to maintain translation quality as the project evolves.
Thank you! You will need to rebase first.
Thank you! You will need to rebase first.
You're welcome! Done.
I’ve done the rebase, this PR is now updated @Andrew-Chen-Wang Could you please check it?
Hi I can accept the translation fixes, but it is obvious you are using AI to generate these test files and PR. It's fine to use AI, but there isn't human-centric thinking going behind those test files. There is no way we'd update the test files because they rely on making sure we update the translations and the test files.
Hi I can accept the translation fixes, but it is obvious you are using AI to generate these test files and PR. It's fine to use AI, but there isn't human-centric thinking going behind those test files. There is no way we'd update the test files because they rely on making sure we update the translations and the test files.
Hi, thank you for the detailed feedback!
I'd like to clarify that none of these tests were generated by AI; they were all written manually. For reference and to show my approach to contributions, here are some of my other pull requests in this and similar projects:
-
djangorestframework-simplejwt:
-
django-rest-framework:
-
Chromium:
Regarding the very problem you pointed out—that the test files need to be updated whenever the translation files change—that was actually an intentional design. The idea was to require that users who modify the translations must also update the corresponding test file. This approach allows us to track which parts of the translations have changed and to identify any potential "breaking changes."
However, I understand your perspective and will follow your guidance. As you suggested, I will remove these two files from this pull request.
In OSS, getting volunteers for translations/contributions in general is very tough. Asking for too much would be a burden. Thanks for understanding.
@Andrew-Chen-Wang Hi, PR updated.