fix(localize): force symbols for locale 'en-AU' (#619)
This commit is contained in:
parent
ad1e828d51
commit
a9ea72b7df
3 changed files with 28 additions and 3 deletions
21
packages/localize/src/number/forceENAUSymbols.js
Normal file
21
packages/localize/src/number/forceENAUSymbols.js
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
export function forceENAUSymbols(formattedParts, options) {
|
||||||
|
const result = formattedParts;
|
||||||
|
const numberOfParts = result.length;
|
||||||
|
// Change the symbols for locale 'en-AU', due to bug in Chrome
|
||||||
|
if (numberOfParts > 1 && options && options.currencyDisplay === 'symbol') {
|
||||||
|
switch (options.currency) {
|
||||||
|
case 'EUR':
|
||||||
|
result[0].value = '€';
|
||||||
|
break;
|
||||||
|
case 'USD':
|
||||||
|
result[0].value = '$';
|
||||||
|
break;
|
||||||
|
case 'JPY':
|
||||||
|
result[0].value = '¥';
|
||||||
|
break;
|
||||||
|
/* no default */
|
||||||
|
}
|
||||||
|
result[1].value = '';
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,7 @@ import { forceSpaceBetweenCurrencyCodeAndNumber } from './forceSpaceBetweenCurre
|
||||||
import { forceYenSymbol } from './forceYenSymbol.js';
|
import { forceYenSymbol } from './forceYenSymbol.js';
|
||||||
import { forceSpaceInsteadOfZeroForGroup } from './forceSpaceInsteadOfZeroForGroup.js';
|
import { forceSpaceInsteadOfZeroForGroup } from './forceSpaceInsteadOfZeroForGroup.js';
|
||||||
import { forceTryCurrencyCode } from './forceTryCurrencyCode.js';
|
import { forceTryCurrencyCode } from './forceTryCurrencyCode.js';
|
||||||
|
import { forceENAUSymbols } from './forceENAUSymbols.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function with all fixes on localize
|
* Function with all fixes on localize
|
||||||
|
|
@ -38,6 +39,9 @@ export function normalizeIntl(formattedParts, options, _locale) {
|
||||||
if (_locale === 'tr-TR') {
|
if (_locale === 'tr-TR') {
|
||||||
normalize = forceTryCurrencyCode(normalize, options);
|
normalize = forceTryCurrencyCode(normalize, options);
|
||||||
}
|
}
|
||||||
|
if (_locale === 'en-AU') {
|
||||||
|
normalize = forceENAUSymbols(normalize, options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return normalize;
|
return normalize;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -210,9 +210,9 @@ describe('formatNumber', () => {
|
||||||
expect(formatNumber(123456.789, currencyCode('EUR'))).to.equal('EUR 123,456.79');
|
expect(formatNumber(123456.789, currencyCode('EUR'))).to.equal('EUR 123,456.79');
|
||||||
expect(formatNumber(123456.789, currencyCode('USD'))).to.equal('USD 123,456.79');
|
expect(formatNumber(123456.789, currencyCode('USD'))).to.equal('USD 123,456.79');
|
||||||
expect(formatNumber(123456.789, currencyCode('JPY'))).to.equal('JPY 123,457');
|
expect(formatNumber(123456.789, currencyCode('JPY'))).to.equal('JPY 123,457');
|
||||||
// expect(formatNumber(123456.789, currencySymbol('EUR'))).to.equal('€123,456.79'); // TODO: fix
|
expect(formatNumber(123456.789, currencySymbol('EUR'))).to.equal('€123,456.79'); // TODO: fix
|
||||||
// expect(formatNumber(123456.789, currencySymbol('USD'))).to.equal('$123,456.79'); // TODO: fix
|
expect(formatNumber(123456.789, currencySymbol('USD'))).to.equal('$123,456.79'); // TODO: fix
|
||||||
// expect(formatNumber(123456.789, currencySymbol('JPY'))).to.equal('¥123,457'); // TODO: fix
|
expect(formatNumber(123456.789, currencySymbol('JPY'))).to.equal('¥123,457'); // TODO: fix
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue