fix: fall back to overall language [DHIS2-17696] #33
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See https://dhis2.atlassian.net/jira/software/c/projects/DHIS2/issues/DHIS2-17696
Changes in PR:
ar_EG
) to the ISO format expected by i18next (e.g.ar-EG
)before
(no translations for Egyptian Arabic and translations do not fall back to Arabic; direction is not set to RTL)
after
(translations fall back to Arabic; direction is set to RTL)
Technical notes:
lng
option). (This was done because calling i18n.changeLanguage would require a page refresh to load translations, which we decided against during the initial implementation). Since i18n.t also supports passinglngs
, I've updated the translation functions to pass two languages (selected code and (if applicable) language e.g.["ar_EG", "ar"]
or["fr"]
)Testing
Manual: I've tested locally (looked at all pages in French) and visually checked that overall languages fallback to the overall language. You can see this on the main page looking at the differences between Portuguese Brazilian and Portuguese (slight difference in username, and Portuguese Brazilian did not have its own translation for "Create an account"
Automated: We don't generally test if strings are wrapped with translation logic, so I haven't done that here (it's an interesting question if it's possible 🧐). I have updated an existing test that touches translations in the "Powered by DHIS2" function and have updated tests for the relevant hooks to make sure fallback language gets set appropriately on language change. Also tests for the insignificant helper parser functions I added.