- Notifications
You must be signed in to change notification settings - Fork6.1k
Add comprehensive login page customization options#7374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
strickvl wants to merge15 commits intocoder:mainChoose a base branch fromstrickvl:main
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes fromall commits
Commits
Show all changes
15 commits Select commitHold shift + click to select a range
cd99956
feat: add comprehensive login page customization options
strickvlbac8b42
Merge branch 'main' into main
strickvl2553f45
feat: replace individual UI flags with unified --custom-strings flag
strickvlc2eb61d
docs: simplify migration guide to only cover released flags
strickvlc0189ed
docs: update Docker customization examples to use --custom-strings
strickvlcacf3cc
Merge branch 'main' into main
strickvl2b2819e
docs: remove niche customization sections from FAQ and install guide
strickvlb275d52
refactor: remove redundant custom-strings validation and global variable
strickvlaf2f599
refactor: simplify loadCustomStrings function signature and error han…
strickvle89a9af
test: remove outdated tests for deprecated custom UI flags
strickvla8b7fbe
refactor: use addResourceBundle instead of re-initializing i18next
strickvl27ee714
docs: improve custom-strings flag description
strickvld5c0c88
refactor: keep --app-name flag as non-deprecated for {{app}} placeholder
strickvlfd6ca51
refactor: rename --custom-strings flag to --i18n
strickvlca12a25
docs: consolidate i18n documentation in guide.md
strickvlFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
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
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
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
1 change: 1 addition & 0 deletionsdocs/install.md
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,60 @@ | ||
import i18next, { init } from "i18next" | ||
import { promises as fs } from "fs" | ||
import * as en from "./locales/en.json" | ||
import * as ja from "./locales/ja.json" | ||
import * as th from "./locales/th.json" | ||
import * as ur from "./locales/ur.json" | ||
import * as zhCn from "./locales/zh-cn.json" | ||
const defaultResources = { | ||
en: { | ||
translation: en, | ||
}, | ||
"zh-cn": { | ||
translation: zhCn, | ||
}, | ||
th: { | ||
translation: th, | ||
}, | ||
ja: { | ||
translation: ja, | ||
}, | ||
ur: { | ||
translation: ur, | ||
}, | ||
} | ||
export async function loadCustomStrings(customStringsArg: string): Promise<void> { | ||
try { | ||
let customStringsData: Record<string, any> | ||
// Try to parse as JSON first | ||
try { | ||
customStringsData = JSON.parse(customStringsArg) | ||
strickvl marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
} catch { | ||
// If JSON parsing fails, treat as file path | ||
const fileContent = await fs.readFile(customStringsArg, "utf8") | ||
customStringsData = JSON.parse(fileContent) | ||
} | ||
// User-provided strings override all languages. | ||
Object.keys(defaultResources).forEach((locale) => { | ||
i18next.addResourceBundle(locale, "translation", customStringsData) | ||
}) | ||
} catch (error) { | ||
throw new Error(`Failed to load custom strings: ${error instanceof Error ? error.message : String(error)}`) | ||
} | ||
} | ||
init({ | ||
lng: "en", | ||
fallbackLng: "en", // language to use if translations in user language are not available. | ||
returnNull: false, | ||
lowerCaseLng: true, | ||
debug: process.env.NODE_ENV === "development", | ||
resources: defaultResources, | ||
}) | ||
export default i18next |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -146,5 +146,6 @@ describe("login", () => { | ||
expect(resp.status).toBe(200) | ||
expect(htmlContent).toContain(`欢迎来到 code-server`) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.