diff --git a/components/dashboard/Countries.tsx b/components/dashboard/Countries.tsx index d54b505..ba03ec9 100644 --- a/components/dashboard/Countries.tsx +++ b/components/dashboard/Countries.tsx @@ -27,6 +27,16 @@ export default function Countries({ countries }: CountriesProps) { return FlagComponent ? : null } + const getCountryName = (code: string) => { + if (!code || code === 'Unknown') return 'Unknown' + try { + const regionNames = new Intl.DisplayNames(['en'], { type: 'region' }) + return regionNames.of(code) || code + } catch (e) { + return code + } + } + return (

@@ -37,7 +47,7 @@ export default function Countries({ countries }: CountriesProps) {
{getFlagComponent(country.country)} - {country.country === 'Unknown' ? 'Unknown' : country.country} + {getCountryName(country.country)}
{formatNumber(country.pageviews)}