fix: Fixes displaying country names which has multiple names listed.
Some countries have multiple names listed in i18n-iso-countries, like US -> ['United States of America', 'USA'].
This commit is contained in:
parent
4369579d2b
commit
33503122c4
|
@ -66,9 +66,20 @@ class NumbersList extends Component<Props> {
|
|||
(resultNumbers, number) => {
|
||||
// The i18n-iso-countries package insists on upper case.
|
||||
const countryCode = number.countryCode.toUpperCase();
|
||||
const countryName = countryCode === 'SIP'
|
||||
? t('info.sip')
|
||||
: t(`countries:countries.${countryCode}`);
|
||||
|
||||
let countryName;
|
||||
|
||||
if (countryCode === 'SIP') {
|
||||
countryName = t('info.sip');
|
||||
} else {
|
||||
countryName = t(`countries:countries.${countryCode}`);
|
||||
|
||||
// Some countries have multiple names as US ['United States of America', 'USA']
|
||||
// choose the first one if that is the case
|
||||
if (!countryName) {
|
||||
countryName = t(`countries:countries.${countryCode}.0`);
|
||||
}
|
||||
}
|
||||
|
||||
if (resultNumbers[countryName]) {
|
||||
resultNumbers[countryName].push(number);
|
||||
|
|
Loading…
Reference in New Issue