fix(cli): fix failure to retrieve OS language (#851)

This commit is contained in:
pengzhanbo 2026-02-14 14:53:23 +08:00 committed by GitHub
parent 9c3899135b
commit 77da8a3470
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<PromptResult> {
let hasTs = false
if (mode === Mode.init) {
@ -21,7 +30,7 @@ export async function prompt(mode: Mode, root?: string): Promise<PromptResult> {
const result: PromptResult = await group({
displayLang: async () => {
const locale = await osLocale()
const locale = osLocale()
if (locale === 'zh-CN' || locale === 'zh-Hans') {
setLang('zh-CN')