Files
mtdb_movie/common/resources/client/i18n/formatted-country-name.tsx
T
maher 511fad8199
Build / run (push) Has been cancelled
Initial commit
2026-05-14 13:42:10 +02:00

18 lines
517 B
TypeScript
Executable File

import {useSelectedLocale} from '@common/i18n/selected-locale';
import {Fragment, memo} from 'react';
interface Props {
code: string;
}
export const FormattedCountryName = memo(({code: countryCode}: Props) => {
const {localeCode} = useSelectedLocale();
const regionNames = new Intl.DisplayNames([localeCode], {type: 'region'});
let formattedName: string | undefined;
try {
formattedName = regionNames.of(countryCode.toUpperCase());
} catch (e) {}
return <Fragment>{formattedName}</Fragment>;
});