Skip to content

Commit 8eabb16

Browse files
committed
fix: use existing flag locale to the login page
1 parent eed3122 commit 8eabb16

File tree

5 files changed

+14
-17
lines changed

5 files changed

+14
-17
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ ci/helm-chart/ @Matthew-Beckett @alexgorbatchev
44

55
docs/install.md @GNUxeava
66

7-
src/node/i18n/locales/zh-cn.json @zhaozhiming
7+
src/node/i18n/locales/zh-cn.json @zhaozhiming

src/node/cli.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ export interface UserProvidedArgs extends UserProvidedCodeArgs {
8888
verbose?: boolean
8989
"app-name"?: string
9090
"welcome-text"?: string
91-
lng?: string
9291
/* Positional arguments. */
9392
_?: string[]
9493
}
@@ -181,7 +180,14 @@ export const options: Options<Required<UserProvidedArgs>> = {
181180
enable: { type: "string[]" },
182181
help: { type: "boolean", short: "h", description: "Show this output." },
183182
json: { type: "boolean" },
184-
locale: { type: "string" }, // The preferred way to set the locale is via the UI.
183+
locale: {
184+
// The preferred way to set the locale is via the UI.
185+
type: "string",
186+
description: `
187+
Set vscode display language and language to show on the login page, more info see
188+
https://en.wikipedia.org/wiki/IETF_language_tag
189+
`,
190+
},
185191
open: { type: "boolean", description: "Open in browser on startup. Does not work remotely." },
186192

187193
"bind-addr": {
@@ -265,13 +271,6 @@ export const options: Options<Required<UserProvidedArgs>> = {
265271
`,
266272
deprecated: true,
267273
},
268-
lng: {
269-
type: "string",
270-
description: `
271-
Language show on login page, more infomations to read up on
272-
https://en.wikipedia.org/wiki/IETF_language_tag.
273-
`,
274-
},
275274
}
276275

277276
export const optionDescriptions = (opts: Partial<Options<Required<UserProvidedArgs>>> = options): string[] => {

src/node/routes/login.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ export class RateLimiter {
2929

3030
const getRoot = async (req: Request, error?: Error): Promise<string> => {
3131
const content = await fs.readFile(path.join(rootPath, "src/browser/pages/login.html"), "utf8")
32-
const lng = req.args["lng"] || "en"
33-
i18n.changeLanguage(lng)
32+
const locale = req.args["locale"] || "en"
33+
i18n.changeLanguage(locale)
3434
const appName = req.args["app-name"] || "code-server"
3535
const welcomeText = req.args["welcome-text"] || (i18n.t("WELCOME", { app: appName }) as string)
3636
let passwordMsg = i18n.t("LOGIN_PASSWORD", { configFile: humanPath(os.homedir(), req.args.config) })

test/unit/node/cli.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ describe("parser", () => {
7070
"--verbose",
7171
["--app-name", "custom instance name"],
7272
["--welcome-text", "welcome to code"],
73-
["--lng", "zh-cn"],
7473
"2",
7574

7675
["--locale", "ja"],
@@ -132,7 +131,6 @@ describe("parser", () => {
132131
verbose: true,
133132
"app-name": "custom instance name",
134133
"welcome-text": "welcome to code",
135-
lng: "zh-cn",
136134
version: true,
137135
"bind-addr": "192.169.0.1:8080",
138136
})

test/unit/node/routes/login.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ describe("login", () => {
139139
expect(htmlContent).toContain(`Welcome to ${appName}`)
140140
})
141141

142-
it("should return correct welcome text when lng is set to non-English", async () => {
142+
it("should return correct welcome text when locale is set to non-English", async () => {
143143
process.env.PASSWORD = previousEnvPassword
144-
const lng = "zh-cn"
145-
const codeServer = await integration.setup([`--lng=${lng}`], "")
144+
const locale = "zh-cn"
145+
const codeServer = await integration.setup([`--locale=${locale}`], "")
146146
const resp = await codeServer.fetch("/login", { method: "GET" })
147147

148148
const htmlContent = await resp.text()

0 commit comments

Comments
 (0)