Skip to content

Backend/i18n: Localize region & spoken language names - #9173

Merged
tristanlabelle merged 12 commits into
developfrom
frontend/feature/localize-spoken-languages
Jun 28, 2026
Merged

Backend/i18n: Localize region & spoken language names#9173
tristanlabelle merged 12 commits into
developfrom
frontend/feature/localize-spoken-languages

Conversation

@tristanlabelle

@tristanlabelle tristanlabelle commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Updates the GetLanguages and GetRegions APIs to return names localized in the current user's locale, at least where the Unicode CLDR defines those translations, which should hold for all regions and most common languages.

In both cases, our database stores 3-char codes, but the Unicode CLDR lookup is by 2-char codes. I had to add a mapping from 3-char codes to 2-char codes (where it exists) as to be able to leverage the CLDR without changing our database tables. In the case of languages, I updated languages.json to add 2-char codes for languages that have one.

In the end this fix is independent from #9169, but that frontend change is still an improvement.

Fixes #8424

Testing

Ran local backend + frontend, added tests.

image image

Backend checklist

  • Added tests for any new code or added a regression test if fixing a bug
  • Run the backend locally and it works
  • Added migrations if there are any database changes, rebased onto develop if necessary for linear migration history

For maintainers

  • Maintainers can push commits to my branch
  • Maintainers can merge this PR for me

@CouchersBot

CouchersBot commented Jun 24, 2026

Copy link
Copy Markdown
Member

Mobile

Install the Dev Tool (iOS via TestFlight, iOS Simulator, or Android .apk) here.

Scan the QR with your phone camera, or tap Open in Dev Tool on the device, to open this branch in the installed Dev Tool dev client.

    iOS         Android    
    QR to open the iOS build         QR to open the Android build    
    Open in Dev Tool         Open in Dev Tool    
Deep links

iOS

couchers-devtool://expo-development-client/?url=https%3A%2F%2Ff5ebb4db--ota.preview.couchershq.org%2Fios%2Fmanifest

Android

couchers-devtool://expo-development-client/?url=https%3A%2F%2Ff5ebb4db--ota.preview.couchershq.org%2Fandroid%2Fmanifest

Web (Vercel)

View the Vercel web preview for this branch.

Backend

Schema Schema diff Sample emails

Other

Protos Backend coverage Web coverage

@tristanlabelle
tristanlabelle marked this pull request as ready for review June 24, 2026 15:19
@tristanlabelle
tristanlabelle requested a review from a team June 24, 2026 15:19
@nabramow

Copy link
Copy Markdown
Member

@tristanlabelle Looks like some web tests are failing!

@tristanlabelle

Copy link
Copy Markdown
Contributor Author

@nabramow , the failures were a fluke / unrelated flakiness. I rebased and tests passed. Ready for ✅

FAIL features/publicTrips/PublicTripsSection.test.tsx (26.293 s)
● PublicTripsSection › create › submits valid form data to createPublicTrip and closes the dialog
thrown: "Exceeded timeout of 10000 ms for a test.

@tristanlabelle tristanlabelle changed the title Backend/i18n: Localize common language names Backend/i18n: Localize common spoken language names Jun 26, 2026
@tristanlabelle tristanlabelle changed the title Backend/i18n: Localize common spoken language names Backend/i18n: Localize region & spoken language names Jun 26, 2026

@aapeliv aapeliv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Babel claims to support RFC3066, which claims to support also the three character codes https://datatracker.ietf.org/doc/html/rfc3066.html#section-2.2

This appears to work for me:

$ uv run --with babel python
Python 3.14.2 (main, Dec  5 2025, 21:11:58) [Clang 21.1.4 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import babel
>>> babel.Locale.parse("fin").get_language_name("swe")
'finska'
>>>

do we then not need modification to the languages source of truth file?

Comment thread app/backend/src/couchers/i18n/localize.py Outdated
@tristanlabelle

Copy link
Copy Markdown
Contributor Author

@aapeliv Thanks for catching the support for 3-letter language codes. I'll remove the extra complexity. We do need the 2-letter code for regions though.

@tristanlabelle
tristanlabelle force-pushed the frontend/feature/localize-spoken-languages branch from 10f9eff to f5ebb4d Compare June 28, 2026 12:52
@tristanlabelle

Copy link
Copy Markdown
Contributor Author

@aapeliv 2-letter language codes are out. Ready for ✅

@tristanlabelle
tristanlabelle enabled auto-merge (squash) June 28, 2026 13:14

@aapeliv aapeliv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sorry one more thing on the backend side!

Comment thread app/backend/src/couchers/i18n/localize.py
Comment thread app/backend/src/couchers/servicers/resources.py
Comment thread app/backend/src/couchers/resources.py
@tristanlabelle

Copy link
Copy Markdown
Contributor Author

@aapeliv , should be good now!

@aapeliv aapeliv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lgtm!

@tristanlabelle
tristanlabelle merged commit 408cc2a into develop Jun 28, 2026
6 checks passed
@tristanlabelle
tristanlabelle deleted the frontend/feature/localize-spoken-languages branch June 28, 2026 15:45
@github-actions github-actions Bot added the release notes: pending Add to stuff that should be included in release notes label Jun 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📝 Release Notes

This PR should be included in the release notes.

Suggested release note:

Localized region and spoken language names across the app so they appear in your selected language where translations are available
🤖 Bot Debug Information

Model: couchers.openai.gpt-5.4
Decision: include
Reasoning: This fixes a visible internationalization issue by showing region and spoken language names in the user's selected language instead of always in English, which is a noticeable improvement for non-English users editing/viewing profile-related fields.

aapeliv added a commit to dymbe/couchers that referenced this pull request Jul 23, 2026
Since Couchers-org#9173, GetLanguages localized all ~300 language names on every
request via babel.Locale.parse, costing ~38ms of CPU per call. The
responses are static per locale, so cache the built protos.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release notes: pending Add to stuff that should be included in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

i18n: Spoken languages are not translatable

4 participants