Repository navigation
Add i18n foundation with next-intl and translate the sidebar - #1248
Open
sapatmohit wants to merge 1 commit into
Open
sapatmohit wants to merge 1 commit into
sapatmohit wants to merge 1 commit into
Conversation
…e-ai#1008) Sets up next-intl without i18n routing, resolves the language from the amcp_locale cookie, then Accept-Language, then English, sets <html lang>, and adds en/de/it messages for the sidebar with a key-parity test. Part 1 of HelpCode-ai#1008; the sign-in form and language switchers follow.
|
👋 Welcome, @sapatmohit, and thanks for opening your first PR on AnythingMCP! A few quick pointers:
Someone from the core team will look at this within ~48h. If you don't hear back, please ping us in Discussions / Q&A. ⭐ While you wait — if you find AnythingMCP useful, a star helps others discover it. |
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First part of #1008, split as suggested in the assignment comment: next-intl without i18n routing, locale resolution,
<html lang>, the three message files with a key-parity test, and the sidebar. The sign-in form and the two language switchers follow in a second PR.next-intl 4.14.9 (latest at the time of writing). Its peer range includes
next ^16.0.0, and it runs on the repo's Next 16.4.2: build and the full e2e suite pass.Changes
src/i18n/config.ts: supported locales (en,de,it) and the resolution order:amcp_localecookie if it holds a supported locale, then the bestAccept-Languagematch by quality (de-AT→de), thenen. An unknown cookie value is ignored.src/i18n/request.ts: next-intl request config. Non-English messages are laid overen.json, so a key missing inde/itshows the English text, never the raw key.next.config.ts:createNextIntlPlugin, inside the existing Sentry wrapper. No middleware and no locale prefixes, soproxy.ts, the rewrites and?redirect=links are unchanged.app/layout.tsx:<html lang>follows the resolved locale; messages are passed once throughNextIntlClientProvideraroundProviders. The layout was alreadyforce-dynamic, so reading the cookie per request adds nothing.messages/{en,de,it}.json:nav.*(group titles, items, Settings, Switch workspace, Log out, the Workspace fallback, the Star on GitHub button).lib/navigation.ts: eachNAVgroup and item gets anidused as its message key. The Englishlabelstays because the command palette searches it; translating the palette is out of scope here.app-sidebar.tsxandgithub-star-button.tsx: hard-coded strings replaced withuseTranslations('nav'). Hrefs and the active-item logic are untouched..github/CONTRIBUTING.md: a short "Translating the UI" section.next-intl 4.14 brings its own dependencies (
@swc/core,@parcel/watcher,@formatjs/*), which is most of thepackage-lock.jsondiff.@parcel/watchermoves from dev-only to a runtime dependency because of that.Self-hosted vs Cloud: identical. Frontend only, no backend, database or
ee/change. The language is a per-browser cookie, so members of one workspace can use different languages.Translations
German and Italian aren't my native languages, so please review those strings. I followed the tone of
content/guides/de(Sie, "Connectors", "Marktplatz", "Audit-Log") andcontent/guides/it(tu, "Connettori", "Impostazioni"). Two translations were shortened to fit the 248px sidebar without truncation: "Stern auf GitHub" / "Stella su GitHub", and "Setup e onboarding".Type
Testing
New
tests/e2e/i18n.spec.ts(7 tests):de-DErenders the sidebar in German withlang="de",it-ITin Italian,fr-FRfalls back to English; theamcp_localecookie wins overAccept-Language; an unsupported cookie value is ignored;de.jsonandit.jsonhave exactly the keys ofen.json.Commands and results:
packages/frontendnpm run lintmain)packages/frontendnpx tsc --noEmit -p tsconfig.jsonpackages/frontendnpm run buildpackages/frontendnpm run test:e2elogin-redirect-*packages/backendnpm testThe 5 backend failures are baseline: the same 5 fail on a clean
maincheckout (database.engine.hana.spec.ts×2,mcp-endpoint.controller.spec.ts×2,first-success.service.spec.ts×1). This PR doesn't touch the backend.Also checked manually against a local backend: switching
amcp_localebetweenen,deanditand reloading, navigating through the sidebar, the workspace menu, and log out.Checklist
npm test): frontend yes; backend has the 5 baseline failures abovepackages/frontend/AGENTS.mdwas rewritten bynext devlocally and is left out, as AGENTS.md asks.Related Issues
Part of #1008