From 77da8a347023f2f4b9d2a4a03c9aa3ef306ca456 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Sat, 14 Feb 2026 14:53:23 +0800 Subject: [PATCH] fix(cli): fix failure to retrieve OS language (#851) --- cli/src/prompt.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cli/src/prompt.ts b/cli/src/prompt.ts index 01650e8b..87c0983c 100644 --- a/cli/src/prompt.ts +++ b/cli/src/prompt.ts @@ -2,7 +2,7 @@ import type { Bundler, Langs, PromptResult } from './types.js' import { createRequire } from 'node:module' import process from 'node:process' import { cancel, confirm, group, select, text } from '@clack/prompts' -import { osLocale } from 'os-locale' +import osLocale from 'os-locale' import { bundlerOptions, deployOptions, DeployType, languageOptions, Mode } from './constants.js' import { setLang, t } from './translate.js' @@ -10,6 +10,15 @@ const require = createRequire(process.cwd()) const REG_DIR_CHAR = /[<>:"\\|?*[\]]/ +/** + * Prompt user for project configuration + * + * 提示用户输入项目配置 + * + * @param mode - Operation mode (init or create) / 操作模式(初始化或创建) + * @param root - Optional root directory path / 可选的根目录路径 + * @returns Resolved prompt result / 解析后的提示结果 + */ export async function prompt(mode: Mode, root?: string): Promise { let hasTs = false if (mode === Mode.init) { @@ -21,7 +30,7 @@ export async function prompt(mode: Mode, root?: string): Promise { const result: PromptResult = await group({ displayLang: async () => { - const locale = await osLocale() + const locale = osLocale() if (locale === 'zh-CN' || locale === 'zh-Hans') { setLang('zh-CN')