Skip to content

fix: i18n requests locale files that don't exist on disk - #1423

Open
xtantaudio wants to merge 1 commit into
meshtastic:mainfrom
xtantaudio:fix/i18n-locale-folder-404s
Open

fix: i18n requests locale files that don't exist on disk#1423
xtantaudio wants to merge 1 commit into
meshtastic:mainfrom
xtantaudio:fix/i18n-locale-folder-404s

Conversation

@xtantaudio

@xtantaudio xtantaudio commented Aug 31, 2026

Copy link
Copy Markdown

Problem

The browser's reported locale (e.g. en-US) is interpolated directly into the translation file request path, but the shipped locale files only exist under the base language code (en), not the full regional variant. Every page load produces 11 404s for missing translation JSON files.

Fix

Normalized the requested locale to match what's actually shipped before the i18next backend fetches it.

Verification

Verified page load now produces zero 404 requests for locale files, tested against multiple browser-reported locale variants.

Summary by CodeRabbit

  • Bug Fixes

    • Improved language detection for regional locale codes, ensuring they resolve to the correct available language.
    • Added reliable fallback to English for unsupported or unavailable languages.
    • Prevented missing translation errors for browser locales such as en-US.
  • Tests

    • Added coverage for locale mapping, fallback behavior, and language picker resolution across supported locales.

@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Meshtastic Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c2bdedea-d8be-44b5-8028-07e7d3df7202

📥 Commits

Reviewing files that changed from the base of the PR and between cffd35f and e834c49.

📒 Files selected for processing (4)
  • apps/web/src/core/hooks/useLang.test.ts
  • apps/web/src/core/hooks/useLang.ts
  • apps/web/src/i18n-config.test.ts
  • apps/web/src/i18n-config.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The PR derives i18n fallbacks from shipped locale folders, centralizes initialization options, validates locale loading against disk files, and updates useLang to resolve regional and unsupported language codes.

Changes

Locale resolution

Layer / File(s) Summary
Shipped locale contract and initialization
apps/web/src/i18n-config.ts
The configuration exports shipped locales, locale parsing, dynamic fallback construction, load path, namespaces, and shared i18next options. Initialization uses these options and disables explicit regional locale requests.
Locale loading validation
apps/web/src/i18n-config.test.ts
Tests compare configured locales with disk folders and validate fallback chains, namespace loading, resolved languages, translation loading, and detected-language mappings without 404 responses.
Language picker resolution
apps/web/src/core/hooks/useLang.ts, apps/web/src/core/hooks/useLang.test.ts
useLang matches exact and regional language codes using resolvedLanguage or language, then falls back to English. Tests cover supported regional codes and th-TH fallback behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to e834c

The change normalizes browser locale variants to the shipped translation folders, preventing failed locale requests without changing broader application behavior. No actionable merge-blocking risk remains beyond normal checks and review.

Poem

A rabbit checks each locale trail

English waits when others fail
Regional paths now point just right
Tests guard every loading flight
The picker hops to codes in sight

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: preventing i18n requests for locale files that do not exist on disk.
Description check ✅ Passed The description explains the problem, the fix, and the verification results. It omits the template headings for Changes Made and Checklist, but the required technical information is present.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@CLAassistant

CLAassistant commented Aug 31, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@xtantaudio
xtantaudio force-pushed the fix/i18n-locale-folder-404s branch from e834c49 to e1e9daf Compare August 31, 2026 03:10
The browser's reported locale (e.g. en-US) was interpolated directly
into the translation file request path, but the shipped locale files
only exist under the base language code (en), not the full regional
variant. Every page load produced 11 404s for missing translation
JSON files.

Normalized the requested locale to match what's actually shipped
before the i18next backend fetches it.

Verified: page load now produces zero 404 requests for locale files.
@xtantaudio
xtantaudio force-pushed the fix/i18n-locale-folder-404s branch from e1e9daf to c493736 Compare August 31, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants