dashboard icon indicating copy to clipboard operation
dashboard copied to clipboard

feat(i18n): expand Chinese localization and fix env substitution

Open sakuradairong opened this issue 5 months ago • 7 comments

Summary

  • Expand the Chinese i18n bundle (en/zh) to cover Groups, Networks, Network Routes, Posture Checks, DNS, Reverse Proxy, Audit, and Settings pages, plus their modals.
  • Fix docker/server.js to substitute both $VAR and $$VAR placeholders at startup, apply no-store to .js assets, and render OidcTrustedDomains.js from the template.
  • Add a safePath guard in the static server so request paths cannot escape the served web root.
  • Localize remaining reverse proxy modal labels, descriptions, tooltips, and the "Learn more about" doc links; move table column definitions for Networks, MinimalPeers, ServiceUsers, and Activity tables into useMemo hooks so they can consume useTranslations (column headers, code, role, status, address, last seen, etc.).
  • Add missing translation keys: dns.selectType/selectTTL, activity.code, policies.all/protocols, postureChecks.descriptionOptional, serviceUsers.{role,status,learnMoreAbout}, networks.policies, and the full reverseProxy modal set (NetBird-Only Access, SSO, Password, PIN Code, HTTP Headers, Preserve Client Source IP, Session/Connection Timeout, Pass Host Header, Rewrite Redirects, Direct Upstream, and the per-tab "Learn more" links).
  • Address CodeRabbit review: localize confirmation dialogs (noProtectionTitle/Description), service mode labels (httpsService, tlsPassthrough, tcpService, udpService), modal descriptions, tooltip text (GROUP_TOOLTIP_TEXT → translation keys), timestamp [at] token, RestrictedAccess heading/description, MultipleGroups badge, PeerNameCell aria-label interpolation, PeerVersionCell latestUrl null-check, DataTableMultiSelectPopup double-count fix, AccessControlTable bidirectional || → ??, and zh.ts ICU plural format for activePoliciesCount.

Verification

  • npx tsc --noEmit
  • npm run build
  • git diff --check
  • Translation key validator (en + zh) for all touched .tsx files
  • Production smoke test on https://ne.rainycy.top/ confirms Chinese rendering and that no unexpanded placeholders leak into the served bundle.

Out of scope

  • Upgrading audited high-severity dependencies (next, js-cookie, etc.) — should be handled in a separate PR.
  • npm run lint — the project still calls the removed next lint script; this is a repo-wide config issue, not a regression introduced here.
  • Translation key gaps in pre-existing dev-authored commits on the same branch (e.g. policies.learnMore, peers.operatingSystem.linux); these are inherited from earlier work and tracked separately.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added multi-language support (English and Chinese) with localized dashboard content, navigation, dialogs, and table controls.
    • Introduced a locale switcher and cookie/browser-based locale detection with safe fallbacks.
  • Refactor

    • Updated dashboard pages and shared components to use translation-driven text, placeholders, tooltips, and status labels across tables and empty states.
  • Deployment

    • Updated the container to serve the built dashboard via a Node-based static server on port 80.

sakuradairong avatar Jun 18 '26 17:06 sakuradairong

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jun 18 '26 17:06 CLAassistant

Review Change Stack

[!NOTE]

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • [ ] ▶️ Resume reviews
  • [ ] 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds next-intl localization across dashboard pages, shared components, and feature tables/modals, introduces English and Chinese message bundles, and replaces the dashboard container with a Node static server for exported assets.

Changes

Dashboard i18n and runtime migration

Layer / File(s) Summary
Runtime and locale bootstrap
docker/*, next.config.js, package.json, src/i18n/*, src/layouts/AppLayout.tsx, src/layouts/Header.tsx, src/modules/settings/LanguageTab.tsx, src/i18n/messages/*
The container runtime now serves exported assets with docker/server.js, and the app is wired for next-intl routing, locale request/config loading, locale persistence, locale switching, and message catalogs.
Dashboard pages and navigation localization
src/app/(dashboard)/*page.tsx, src/layouts/Navigation.tsx, src/modules/settings/*Tab.tsx
Dashboard route pages, sidebar labels, and settings tabs switch their visible text to translation keys while preserving existing data loading, permission checks, and navigation structure.
Shared UI and table primitives
src/components/table/*, src/components/ui/*, src/components/PeerSelector.tsx, src/components/NoPeersGettingStarted.tsx, src/modules/common-table-rows/GroupsRow.tsx, src/modules/groups/*Selector.tsx, src/modules/control-center/nodes/SelectGroupNode.tsx, src/modules/peer/MinimalPeersTable.tsx, src/components/ui/RestrictedAccess.tsx
Reusable tables, selectors, empty states, group helpers, and restricted-access text now use translated labels, placeholders, modal copy, and fallback text.
Feature tables and modals
src/modules/access-control/*, src/modules/activity/ActivityTable.tsx, src/modules/groups/table/*, src/modules/users/UsersTable.tsx, src/modules/users/ServiceUsersTable.tsx, src/modules/peers/*, src/modules/networks/*, src/modules/reverse-proxy/ReverseProxyModal.tsx, src/modules/dns/*, src/modules/posture-checks/modal/PostureCheckModal.tsx
Access-control, activity, groups, service-users, users, peers, network, reverse-proxy, DNS, and posture-check tables, action cells, and modals are localized, with several table column definitions moved into component-local memoized builders.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~90+ minutes

Possibly related PRs

  • netbirdio/dashboard#485: Both PRs modify src/app/(dashboard)/peer/page.tsx, so they overlap on the peer detail page component.
  • netbirdio/dashboard#528: Both PRs touch src/app/(dashboard)/dns/zones/page.tsx, which is one of the localized DNS route pages here.
  • netbirdio/dashboard#552: Both PRs overlap on reverse-proxy page components that this PR localizes.

Poem

🐇 I hopped through pages, strings, and signs,
and stitched two tongues through rabbit lines.
The static shell now hums at night,
while en and zh both shine bright.
A tidy burrow, softly sprung—
the dashboard sings in every tongue.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.27% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description provides detailed summary, verification steps, and explicitly marks out-of-scope items, but does not follow the required template structure with Issue ticket, Documentation checkboxes, and Docs PR URL. Follow the repository's PR description template: add Issue ticket number/link section, select Documentation checkbox with explanation, and include Docs PR URL if applicable.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main changes: i18n expansion and Docker environment variable substitution fixes.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests

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.

coderabbitai[bot] avatar Jun 18 '26 17:06 coderabbitai[bot]

@sakuradairong we are about to merge a huge change where we sync a private fork into this repo. This will cause lots of changes for your PR.

I advise you to wait for a bit as this may break things for you.

mlsmaycon avatar Jun 20 '26 14:06 mlsmaycon

Thank you for the heads up! I will pause further changes and wait for the private fork merge to land first. After that I will rebase this PR and resolve any conflicts.

For context, this PR adds:

  • Cookie-based locale detection (enabled by default, switchable to zh via cookie)
  • Language switcher in the header and Settings page
  • Comprehensive Chinese localization (~900 translation keys)

Please let me know when the fork merge is complete and I will update the PR accordingly.

sakuradairong avatar Jun 20 '26 14:06 sakuradairong

Good catch on the LOCALE_LABELS duplication. I will address this after rebasing on the upcoming fork merge.

sakuradairong avatar Jun 20 '26 14:06 sakuradairong

Update: the Chinese translation work is now mostly complete.

I have pushed the latest localization updates covering the shared UI and the main dashboard modules, including Peers, Users, Activity, Setup Keys, Routes, DNS, Networks, and Access Control. At this point the remaining work should mainly be review, final polish, and addressing any feedback or conflicts from upstream changes.

Thanks!

sakuradairong avatar Jun 24 '26 08:06 sakuradairong

Hi team, I''ve synced the latest origin/main into this branch and fixed the blockers that were preventing a green build. Here is a summary:

Fixes applied

  • Merged origin/main (non-fast-forward merge) to resolve the API drift.
  • Replaced removed export isNetBirdHosted → isNetBirdCloud in:
    • src/modules/settings/GroupsSettings.tsx
    • src/modules/settings/NetworkSettingsTab.tsx
  • Restored missing imports IdentityProviderCard and AccountMfaCard in src/app/(dashboard)/team/users/page.tsx.
  • Fixed PeerMultiSelect scope bug where the inner component used t without calling useTranslations("peers").
  • Added dataCy prop support to PeerGroupSelector so callers that pass dataCy type-check correctly.
  • Fixed translator type mismatch in AccessControlTable column factory.
  • Fixed next-intl value type errors in:
    • ActivityDescription.tsx (nested t.rich returning ReactNode used as interpolation value)
    • UserResendInviteButton.tsx (user.email possibly undefined)
  • Addressed CodeRabbit feedback:
    • Extracted shared LOCALE_LABELS into src/i18n/config.ts and updated both LocaleSwitcher and LanguageTab to import it.
    • Removed the unsafe zh: zh as unknown as typeof en cast from src/i18n/config.ts.

Verification

  • npx tsc --noEmit ✅ 0 errors
  • npm run build ✅ static export completed successfully
  • i18n key parity check: en.ts and zh.ts both have 2483 keys, missingInZh = 0, extraInZh = 0
  • Changed-file translation usage check: missingCount = 0

Notes

  • The npm run lint / ESLint 9 setup issue is unrelated to this localization work and is still tracked separately.
  • Branch localize-zh-v2.39.0 has been pushed to both fork and rainycy remotes.

Please re-run the checks when convenient. Let me know if anything else is needed!

sakuradairong avatar Jun 24 '26 09:06 sakuradairong

Hi @mlsmaycon, the private-fork changes have now landed and I have updated this PR against the latest origin/main (through v2.90.7).

I also performed a full regression review after the sync and fixed the issues introduced during conflict resolution:

  • restored the Reverse Proxy Events pagination/peer providers and default date/sort filters;
  • preserved the current Cloud/Billing, Metrics, MSP, and Agent Network settings behavior;
  • restored the upstream nginx/supervisor/certbot runtime, TLS/443 support, CSP/security headers, and runtime environment substitution (including both $VAR and $$VAR placeholders);
  • fixed the peer-count label, restricted-access fallback, and stale translated filter memo dependencies;
  • added a Node 20-compatible test:i18n command and completed another shared UI / Reverse Proxy Events localization pass.

Verification completed successfully:

  • npm run build
  • npx tsc --noEmit --pretty false
  • npm run test:i18n
  • git diff --check
  • English/Chinese catalog parity: 2,594 keys on each side, with no missing or extra keys
  • Docker image build and live nginx/CSP/runtime-environment smoke test

The latest commit is b3b9ab6. CodeRabbit and CLA checks are green. The branch is currently fully synced with origin/main (58 commits ahead, 0 behind).

This should now be ready for another maintainer review. Please let me know if you would prefer the history to be squashed or if any additional changes are needed. Thank you!

sakuradairong avatar Jul 24 '26 10:07 sakuradairong