[PR #6739] feat: add i18n support for login page with zh-CN translations #29852

Open
opened 2026-08-05 08:09:10 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6739
Author: @ocoj
Created: 7/12/2026
Status: 🔄 Open

Base: mainHead: i18n-login-zh


📝 Commits (2)

  • 102d613 feat: add i18n support for login page templates via Extra config map
  • cde17ef feat: add Frontend.Locale and zh-CN translations for login page

📊 Changes

3 files changed (+106 additions, -43 deletions)

View changed files

📝 idp/dex/config.go (+94 -31)
📝 idp/dex/web/templates/login.html (+4 -4)
📝 idp/dex/web/templates/password.html (+8 -8)

📄 Description

Summary

This PR adds internationalization (i18n) support for the embedded IdP login page, with Chinese (zh-CN) translations included.

Previously, all login page text was hardcoded in English. Users deploying NetBird for Chinese-speaking teams had no way to localize the login experience.

Changes

1. Template i18n (idp/dex/web/templates/)

  • login.html and password.html: Replaced hardcoded English text with {{ .Extra.xxx }} template variables with English fallbacks
  • All existing deployments continue to work unchanged (fallback to English)

2. Frontend config (idp/dex/config.go)

  • Added Locale field to Frontend struct
  • Added FrontendI18n struct and GetI18n() function
  • Added ToExtraMap() helper to convert translations to template Extra map
  • ToServerConfig() merges locale-based translations into the Extra map

3. Translations included

  • zh-CN: Full Chinese translations for all login page strings

How to use

frontend:
  issuer: "NetBird"
  theme: "light"
  locale: "zh-CN"  # Add this line

Or programmatically:

config.Frontend.Locale = "zh-CN"

Screenshots

Before (English):

  • "Sign in" / "Enter your credentials" / "Email Address" / "Password"

After (zh-CN):

  • "登录" / "请输入您的凭据" / "邮箱地址" / "密码"

Backward Compatibility

  • If locale is not set or empty, all templates fall back to the original English text
  • The Extra map can still be used for custom overrides, which take precedence over locale translations

Summary by CodeRabbit

  • New Features
    • Added locale-based translations for login page text.
    • Added configurable labels for connector buttons, sign-in headings, form fields, validation messages, submit actions, and navigation links.
    • Added fallback text so existing login behavior remains unchanged when translations are unavailable.
    • Added frontend locale configuration support for selecting translated content.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/6739 **Author:** [@ocoj](https://github.com/ocoj) **Created:** 7/12/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `i18n-login-zh` --- ### 📝 Commits (2) - [`102d613`](https://github.com/netbirdio/netbird/commit/102d613ad15689a2391314973aee07923619db7b) feat: add i18n support for login page templates via Extra config map - [`cde17ef`](https://github.com/netbirdio/netbird/commit/cde17ef40133ec2ea00c1e4b193f75871e8dcacd) feat: add Frontend.Locale and zh-CN translations for login page ### 📊 Changes **3 files changed** (+106 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `idp/dex/config.go` (+94 -31) 📝 `idp/dex/web/templates/login.html` (+4 -4) 📝 `idp/dex/web/templates/password.html` (+8 -8) </details> ### 📄 Description ## Summary This PR adds internationalization (i18n) support for the embedded IdP login page, with Chinese (zh-CN) translations included. Previously, all login page text was hardcoded in English. Users deploying NetBird for Chinese-speaking teams had no way to localize the login experience. ## Changes ### 1. Template i18n (`idp/dex/web/templates/`) - **`login.html`** and **`password.html`**: Replaced hardcoded English text with `{{ .Extra.xxx }}` template variables with English fallbacks - All existing deployments continue to work unchanged (fallback to English) ### 2. Frontend config (`idp/dex/config.go`) - Added `Locale` field to `Frontend` struct - Added `FrontendI18n` struct and `GetI18n()` function - Added `ToExtraMap()` helper to convert translations to template `Extra` map - `ToServerConfig()` merges locale-based translations into the `Extra` map ### 3. Translations included - **zh-CN**: Full Chinese translations for all login page strings ## How to use ```yaml frontend: issuer: "NetBird" theme: "light" locale: "zh-CN" # Add this line ``` Or programmatically: ```go config.Frontend.Locale = "zh-CN" ``` ## Screenshots **Before (English):** - "Sign in" / "Enter your credentials" / "Email Address" / "Password" **After (zh-CN):** - "登录" / "请输入您的凭据" / "邮箱地址" / "密码" ## Backward Compatibility - If `locale` is not set or empty, all templates fall back to the original English text - The `Extra` map can still be used for custom overrides, which take precedence over locale translations <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added locale-based translations for login page text. - Added configurable labels for connector buttons, sign-in headings, form fields, validation messages, submit actions, and navigation links. - Added fallback text so existing login behavior remains unchanged when translations are unavailable. - Added frontend locale configuration support for selecting translated content. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 08:09:10 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#29852