fix(localize): if locale is set to tr, currency TRY should display TL
This commit is contained in:
parent
4ce24576a7
commit
8fb3b23755
3 changed files with 26 additions and 0 deletions
10
packages/localize/src/number/forceTryCurrencyCode.js
Normal file
10
packages/localize/src/number/forceTryCurrencyCode.js
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
export function forceTryCurrencyCode(formattedParts, options) {
|
||||||
|
const result = formattedParts;
|
||||||
|
// Chage the currencycode from TRY to TL, for Turkey
|
||||||
|
if (options.currency === 'TRY' && options.currencyDisplay === 'code') {
|
||||||
|
if (result[0].value === 'TRY') {
|
||||||
|
result[0].value = 'TL';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ import { forceNormalSpaces } from './forceNormalSpaces.js';
|
||||||
import { forceSpaceBetweenCurrencyCodeAndNumber } from './forceSpaceBetweenCurrencyCodeAndNumber.js';
|
import { forceSpaceBetweenCurrencyCodeAndNumber } from './forceSpaceBetweenCurrencyCodeAndNumber.js';
|
||||||
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';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function with all fixes on localize
|
* Function with all fixes on localize
|
||||||
|
|
@ -34,6 +35,9 @@ export function normalizeIntl(formattedParts, options, _locale) {
|
||||||
if (_locale === 'fr-FR' || _locale === 'fr-BE') {
|
if (_locale === 'fr-FR' || _locale === 'fr-BE') {
|
||||||
normalize = forceYenSymbol(normalize, options);
|
normalize = forceYenSymbol(normalize, options);
|
||||||
}
|
}
|
||||||
|
if (_locale === 'tr-TR') {
|
||||||
|
normalize = forceTryCurrencyCode(normalize, options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return normalize;
|
return normalize;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -308,5 +308,17 @@ describe('formatNumber', () => {
|
||||||
expect(formatNumber(123456.789, currencySymbol('CZK'))).to.equal('123 456,79 Kč');
|
expect(formatNumber(123456.789, currencySymbol('CZK'))).to.equal('123 456,79 Kč');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('tr-TR', () => {
|
||||||
|
localize.locale = 'tr-TR';
|
||||||
|
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('JPY'))).to.equal('JPY 123.457');
|
||||||
|
expect(formatNumber(123456.789, currencyCode('TRY'))).to.equal('TL 123.456,79');
|
||||||
|
expect(formatNumber(123456.789, currencySymbol('EUR'))).to.equal('€123.456,79');
|
||||||
|
expect(formatNumber(123456.789, currencySymbol('USD'))).to.equal('$123.456,79');
|
||||||
|
expect(formatNumber(123456.789, currencySymbol('JPY'))).to.equal('¥123.457');
|
||||||
|
expect(formatNumber(123456.789, currencySymbol('TRY'))).to.equal('₺123.456,79');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue