Skip to content

Commit 79a8c4e

Browse files
committed
🎨 Cleaned up country names in Post analytics
ref https://linear.app/tryghost/issue/NY-1365/ - mirrored the cleanup from the Web analytics PR (#28708) in the Post analytics web tab: the Locations card and the country filter showed the official ISO names from i18n-iso-countries ("Russian Federation", "Taiwan, Province of China", …) - switched the library lookup to {select: 'alias'} so the short/common form is returned when one exists - added the same explicit overrides for entries where i18n-iso-countries has no alias or picks the wrong form: GB → United Kingdom, KR → South Korea, LA → Laos, MD → Moldova, SY → Syria - dropped the now-redundant US/TW/TWN/CN entries from the posts app's STATS_LABEL_MAPPINGS
1 parent d98794b commit 79a8c4e

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

apps/posts/src/utils/constants.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ export const STATS_RANGES = {
99
} as const;
1010

1111
export const STATS_LABEL_MAPPINGS = {
12-
// Countries
13-
US: 'United States',
14-
TWN: 'Taiwan',
15-
TW: 'Taiwan',
16-
CN: 'China',
12+
// Countries — overrides where i18n-iso-countries has no friendly alias,
13+
// or where the alias-mode pick isn't the common short form.
14+
GB: 'United Kingdom',
15+
KR: 'South Korea',
16+
LA: 'Laos',
17+
MD: 'Moldova',
18+
SY: 'Syria',
1719

1820
// Technical
1921
'mobile-ios': 'iOS',

apps/posts/src/views/PostAnalytics/Web/components/locations.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {STATS_LABEL_MAPPINGS} from '@src/utils/constants';
88

99
countries.registerLocale(enLocale);
1010
const getCountryName = (label: string) => {
11-
return STATS_LABEL_MAPPINGS[label as keyof typeof STATS_LABEL_MAPPINGS] || countries.getName(label, 'en') || 'Unknown';
11+
return STATS_LABEL_MAPPINGS[label as keyof typeof STATS_LABEL_MAPPINGS] || countries.getName(label, 'en', {select: 'alias'}) || 'Unknown';
1212
};
1313

1414
interface ProcessedLocationData {

apps/posts/src/views/PostAnalytics/components/stats-filter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface StatsFilterProps extends Omit<React.ComponentProps<typeof Filters>, 'f
2020

2121
// Helper to get country name from code
2222
const getCountryName = (code: string): string => {
23-
return STATS_LABEL_MAPPINGS[code as keyof typeof STATS_LABEL_MAPPINGS] || countries.getName(code, 'en') || code;
23+
return STATS_LABEL_MAPPINGS[code as keyof typeof STATS_LABEL_MAPPINGS] || countries.getName(code, 'en', {select: 'alias'}) || code;
2424
};
2525

2626
// Helper component for visit count badge - used by all filter options

0 commit comments

Comments
 (0)