-
Notifications
You must be signed in to change notification settings - Fork 6.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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
strickvl
wants to merge
15
commits into
coder:main
Choose a base branch
from
strickvl: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.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
cd99956
feat: add comprehensive login page customization options
strickvl bac8b42
Merge branch 'main' into main
strickvl 2553f45
feat: replace individual UI flags with unified --custom-strings flag
strickvl c2eb61d
docs: simplify migration guide to only cover released flags
strickvl c0189ed
docs: update Docker customization examples to use --custom-strings
strickvl cacf3cc
Merge branch 'main' into main
strickvl 2b2819e
docs: remove niche customization sections from FAQ and install guide
strickvl b275d52
refactor: remove redundant custom-strings validation and global variable
strickvl af2f599
refactor: simplify loadCustomStrings function signature and error han…
strickvl e89a9af
test: remove outdated tests for deprecated custom UI flags
strickvl a8b7fbe
refactor: use addResourceBundle instead of re-initializing i18next
strickvl 27ee714
docs: improve custom-strings flag description
strickvl d5c0c88
refactor: keep --app-name flag as non-deprecated for {{app}} placeholder
strickvl fd6ca51
refactor: rename --custom-strings flag to --i18n
strickvl ca12a25
docs: consolidate i18n documentation in guide.md
strickvl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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) | ||
} 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: { | ||
en: { | ||
translation: en, | ||
}, | ||
"zh-cn": { | ||
translation: zhCn, | ||
}, | ||
th: { | ||
translation: th, | ||
}, | ||
ja: { | ||
translation: ja, | ||
}, | ||
ur: { | ||
translation: ur, | ||
}, | ||
}, | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.