Skip to content

feat(i18n): localize event location country names#17925

Merged
wackerow merged 7 commits into
devfrom
location-translations
Apr 20, 2026
Merged

feat(i18n): localize event location country names#17925
wackerow merged 7 commits into
devfrom
location-translations

Conversation

@myelinated-wackerow
Copy link
Copy Markdown
Collaborator

@myelinated-wackerow myelinated-wackerow commented Apr 3, 2026

Summary

  • Add i18n-iso-countries package to translate country names in event locations into the user's locale
  • Event cards now display localized country names (e.g., "Denver, USA" becomes "Denver, アメリカ合衆国" on Japanese pages)
  • City names remain in Latin script; country-only translation as MVP
  • Added reusable getCountryTranslation() utility for use anywhere in the repo

How it works

  • getCountryTranslation(country, locale) -- accepts informal English country names ("USA", "United States", "Hong Kong SAR"), returns localized name via i18n-iso-countries
  • localizeLocation(location, locale) -- parses "City, Country" strings, translates the country portion, reassembles
  • Falls back to the original string if country is unrecognized or locale is English

Changes

  • src/lib/utils/geography.ts -- new getCountryTranslation() and localizeLocation() functions
  • app/[locale]/community/events/_components/EventCard.tsx -- grid and highlight variants
  • app/[locale]/community/events/_components/ContinentTabs.tsx -- table view
  • app/[locale]/page.tsx -- homepage event cards
  • package.json -- added i18n-iso-countries (MIT, 1.6M weekly downloads)

Test plan

  • Verify Netlify build passes
  • Check /community/events/ on a non-English locale (e.g., /ja/community/events/) -- country names should be translated
  • Check homepage event cards on a non-English locale
  • Verify "Online" events are unaffected
  • Verify English pages are unchanged

Reviewed by Claude Opus 4.6

Add i18n-iso-countries package and country translation
utilities to geography.ts. Event locations on community
events pages and homepage now display translated country
names (e.g., "Denver, USA" -> "Denver, アメリカ合衆国").

- getCountryTranslation(): reusable country name lookup
- localizeLocation(): parses "City, Country" and translates
- Updated EventCard, ContinentTabs, and homepage events
- City names remain in Latin script (country-only MVP)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: wackerow <54227730+wackerow@users.noreply.github.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 3, 2026

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 0138c54
🔍 Latest deploy log https://app.netlify.com/projects/ethereumorg/deploys/69e6925991d8028833fc8a25
😎 Deploy Preview https://deploy-preview-17925.ethereum.it
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 58 (🟢 up 3 from production)
Accessibility: 93 (no change from production)
Best Practices: 100 (🟢 up 1 from production)
SEO: 98 (🔴 down 1 from production)
PWA: 59 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added dependencies 📦 Changes related to project dependencies tooling 🔧 Changes related to tooling of the project labels Apr 3, 2026
Copy link
Copy Markdown
Member

@pettinarip pettinarip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wackerow looks good. Found that there are some places that we are not applying this localization

/community/events/ when you search an event, the cards don't get localized
Image

and

/community/events/meetups/
Image

# Conflicts:
#	app/[locale]/page.tsx
#	pnpm-lock.yaml
@wackerow
Copy link
Copy Markdown
Member

Thanks! On it

myelinated-wackerow and others added 4 commits April 20, 2026 11:45
Pre-translate the event location field at the server level
(in mapEventTranslations and getMeetupGroups) rather than
calling localizeLocation inside client components. Client-side
i18n-iso-countries needs locale data registered, which would
bloat the bundle. Doing translation server-side keeps client
components dumb and keeps the bundle lean.

Fixes untranslated locations on /community/events/ search
results and /community/events/meetups/.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: wackerow <54227730+wackerow@users.noreply.github.com>
External event data sometimes uses "Remote" instead of "Online"
for virtual events. Normalize both to the same isOnline flag so
they render with the same translated "Online" tag in the UI.

- Added isOnlineLocation() helper with a set of sentinel values
- Used in fetchEvents, parseLocationToContinent, localizeLocation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: wackerow <54227730+wackerow@users.noreply.github.com>
@wackerow wackerow merged commit 2f8df0a into dev Apr 20, 2026
10 checks passed
@wackerow wackerow deleted the location-translations branch April 20, 2026 23:32
@wackerow wackerow mentioned this pull request Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies 📦 Changes related to project dependencies tooling 🔧 Changes related to tooling of the project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants