Skip to content

Commit

Permalink
fix: pass valid locale for number formatting [DHIS2-17709] (#1352)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomzemp authored Jul 15, 2024
1 parent 0dd67d2 commit 460a87a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/settingsKeyMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ const canBeOverridenLabel = i18n.t(
'This setting can be overridden by user settings'
)

const parseLocale = (localeString) => {
const [language, country] = (localeString ?? 'en').split(/[-_]/)
return `${language}${country ? `-${country}` : ''}`
}

const parsedLocale = parseLocale(i18n.language)

const formatNumber = (value) =>
new Intl.NumberFormat(i18n.language).format(value)
new Intl.NumberFormat(parsedLocale).format(value)

/**
* This file provides information about DHIS2 system settings and configuration options that are not otherwise
Expand Down

0 comments on commit 460a87a

Please sign in to comment.