Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle java language format [DHIS2-18031] #395

Closed
wants to merge 2 commits into from

Conversation

tomzemp
Copy link
Member

@tomzemp tomzemp commented Sep 11, 2024

See https://dhis2.atlassian.net/jira/software/c/projects/DHIS2/issues/DHIS2-18031

Background

This ticket converts keyUiLocale from the Java format (e.g. pt_BR) to the ISO format (pt-BR). The app is currently crashing because the functions to generate periods within multi-calendar-dates fails when passed a locale string.

Note: We also have two UI locales that include script (uz_UZ_Cyrl, uz_UZ_Latn), which in valid ISO format would be (uz-Cyrl-UZ, uz-Latn-UZ), but these cause problems in multi-calendar-dates even when passed in the proper ISO format, so for not I am just removing the potential script tag and converting to uz-UZ (probably need a follow up for multi-calendar-dates to handle languages with scripts)

Before
image

After
image

Testing

Manual: I have tested with Portuguese (Brazilian), Arabic (Egyptian), English, Portuguese, Arabic, French, and the two varieties of Uzbek

Automated: I have added some tests for the useUserInfo hook to test that the conversion of the language code occurs as expected.

@tomzemp tomzemp requested a review from a team September 11, 2024 07:44
@dhis2-bot
Copy link
Contributor

🚀 Deployed on https://pr-395--dhis2-data-entry.netlify.app

@dhis2-bot dhis2-bot temporarily deployed to netlify September 11, 2024 07:46 Inactive
}

// while script is possible in DHIS2 locales, it is not supported in underlying multi-calendar-dates logic
const [lng, region] = unparsedLocale?.replace(/_/g, '-').split('-')
Copy link
Member Author

Choose a reason for hiding this comment

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

the language codes returned from the backend should use _ instead of -, but I'm doing a replace before split in case any start being returned in the ISO format

@tomzemp
Copy link
Member Author

tomzemp commented Oct 22, 2024

Closing because the bug of the app crashing was indirectly fixed by #397 (and the supporting updates to the multi-calendar library)

@tomzemp tomzemp closed this Oct 22, 2024
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.

2 participants