Skip to content

Conversation

@d-rita
Copy link
Contributor

@d-rita d-rita commented Oct 30, 2025

Implements LIBS-798


Description

The previous implementation does not parse the locales with variants well enough to trigger the relevant change in language in the UI. When we pass a keyUILocale that is a language variant, say pt_BR directly to i18n.changeLanguage, it will not be picked up and the UI defaults to English.

In this implementation, we parse locales using the same functionality in the app platform's adapter. It reformats the locale to follow the BCP 47 syntax. For example, pt_Br becomes pt-Br which triggers the translation.


Checklist

  • API docs are generated
  • Tests were added
  • Storybook demos were added

All points above should be relevant for feature PRs. For bugfixes, some points might not be relevant. In that case, just check them anyway to signal the work is done.


Screenshots

For 'pt_Br'
pt_Br

@d-rita d-rita requested a review from a team as a code owner October 30, 2025 14:01
@sonarqubecloud
Copy link

@dhis2-bot
Copy link
Contributor

🚀 Deployed on https://pr-1707--dhis2-ui.netlify.app

@dhis2-bot dhis2-bot temporarily deployed to netlify October 30, 2025 14:04 Inactive
@d-rita d-rita marked this pull request as draft October 30, 2025 15:17
Copy link
Contributor

@KaiVandivier KaiVandivier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this would be perfect... if DHIS2 locale handling made sense 😅 instead, it's currently going the "wrong way"

--> Our input is either pt-BR (BCP-47, v42+) or pt_BR (Java .toString, <v42), and our output needs to be pt_BR (the Java.toString format) for the transifex files we have

P.S., testing can be confusing: it seems that if you set i18n.changeLanguage('pt-BR'), something works in a way that it falls back to pt -- I can tell since I looked at the translations in pt_BR.po and pt.po, and some strings are not translated for pt_BR, like "Search for apps". When using pt-BR as the language, though, "Search for apps" is translated, so it must be getting that from the pt.po file (since we don't have the fallback logic here yet)

I think adding this function can sort everything out: https://github.com/dhis2/app-platform/blob/master/adapter/src/utils/localeUtils.js#L59

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants