lion/packages/localize/src/number/forceTryCurrencyCode.js
Joren Broekema 09d9675963 feat(localize): add types to localize
Co-authored-by: narzac <narzac@gmail.com>
2020-08-03 17:00:26 +02:00

18 lines
623 B
JavaScript

/**
* @typedef {import('../../types/LocalizeMixinTypes').FormatNumberPart} FormatNumberPart
* @param {FormatNumberPart[]} formattedParts
* @param {Object} [options]
* @param {string} [options.currency]
* @param {string} [options.currencyDisplay]
* @returns {FormatNumberPart[]}
*/
export function forceTryCurrencyCode(formattedParts, { currency, currencyDisplay } = {}) {
const result = formattedParts;
// Change the currency code from TRY to TL, for Turkey
if (currency === 'TRY' && currencyDisplay === 'code') {
if (result[0].value === 'TRY') {
result[0].value = 'TL';
}
}
return result;
}