Skip to content

Commit c151f01

Browse files
tlouissedaKmoR
authored andcommitted
fix(localize): for bg-BG locale, correct Intl output for group separator
1 parent 92a548f commit c151f01

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @desc Intl uses 0 as group separator for bg-BG locale.
3+
* This should be a ' '
4+
* @param {{type,value}[]} formattedParts
5+
* @returns {{type,value}[]} corrected formatted parts
6+
*/
7+
export function forceSpaceInsteadOfZeroForGroup(formattedParts) {
8+
return formattedParts.map(p => {
9+
if (p.type === 'group' && p.value === '0') {
10+
p.value = ' '; // eslint-disable-line no-param-reassign
11+
}
12+
return p;
13+
});
14+
}

packages/localize/src/number/normalizeIntl.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { forceCurrencyToEnd } from './forceCurrencyToEnd.js';
44
import { forceNormalSpaces } from './forceNormalSpaces.js';
55
import { forceSpaceBetweenCurrencyCodeAndNumber } from './forceSpaceBetweenCurrencyCodeAndNumber.js';
66
import { forceYenSymbol } from './forceYenSymbol.js';
7+
import { forceSpaceInsteadOfZeroForGroup } from './forceSpaceInsteadOfZeroForGroup.js';
78

89
/**
910
* Function with all fixes on localize
@@ -23,6 +24,7 @@ export function normalizeIntl(formattedParts, options, _locale) {
2324
// Add group separator for Bulgarian locale
2425
if (_locale === 'bg-BG') {
2526
normalize = forceAddGroupSeparators(normalize, getGroupSeparator());
27+
normalize = forceSpaceInsteadOfZeroForGroup(normalize);
2628
}
2729
// Force space between currency code and number
2830
if (_locale === 'en-GB' || _locale === 'en-US' || _locale === 'en-AU') {

0 commit comments

Comments
 (0)