1- import React , { useEffect , useMemo , useState } from "react" ;
1+ import React , { useEffect , useState } from "react" ;
22import { useInput } from "ink" ;
33import DropdownMenu from "../../DropdownMenu" ;
44import { t , type Locale } from "../../../common/i18n" ;
@@ -8,20 +8,38 @@ type ConfigStep = "category" | "language";
88type CategoryOption = {
99 key : "locale" | "thinkingLocale" | "replyLocale" ;
1010 label : string ;
11+ description : string ;
1112} ;
1213
13- function getCategoryOptions ( ) : CategoryOption [ ] {
14+ function getLocaleDisplayName ( locale : Locale ) : string {
15+ return locale === "en" ? t ( "ui.config.localeEn" ) : t ( "ui.config.localeZhCN" ) ;
16+ }
17+
18+ function getCategoryOptions (
19+ currentLocale : Locale ,
20+ currentThinkingLocale : Locale ,
21+ currentReplyLocale : Locale
22+ ) : CategoryOption [ ] {
1423 return [
15- { key : "locale" , label : t ( "ui.config.language" ) } ,
16- { key : "thinkingLocale" , label : t ( "ui.config.thinkingLanguage" ) } ,
17- { key : "replyLocale" , label : t ( "ui.config.replyLanguage" ) } ,
24+ {
25+ key : "locale" ,
26+ label : t ( "ui.config.language" ) ,
27+ description : getLocaleDisplayName ( currentLocale ) ,
28+ } ,
29+ {
30+ key : "thinkingLocale" ,
31+ label : t ( "ui.config.thinkingLanguage" ) ,
32+ description : getLocaleDisplayName ( currentThinkingLocale ) ,
33+ } ,
34+ {
35+ key : "replyLocale" ,
36+ label : t ( "ui.config.replyLanguage" ) ,
37+ description : getLocaleDisplayName ( currentReplyLocale ) ,
38+ } ,
1839 ] ;
1940}
2041
21- const LOCALE_OPTIONS : { key : Locale ; label : string } [ ] = [
22- { key : "en" , label : "English" } ,
23- { key : "zh-CN" , label : "中文" } ,
24- ] ;
42+ const LOCALE_OPTIONS : { key : Locale } [ ] = [ { key : "en" } , { key : "zh-CN" } ] ;
2543
2644type Props = {
2745 open : boolean ;
@@ -73,7 +91,7 @@ const ConfigDropdown: React.FC<Props> = ({
7391
7492 function handleSelect ( ) : void {
7593 if ( step === "category" ) {
76- const category = getCategoryOptions ( ) [ activeIndex ] ;
94+ const category = getCategoryOptions ( currentLocale , currentThinkingLocale , currentReplyLocale ) [ activeIndex ] ;
7795 if ( ! category ) {
7896 return ;
7997 }
@@ -110,7 +128,10 @@ const ConfigDropdown: React.FC<Props> = ({
110128 return ;
111129 }
112130
113- const optionCount = step === "category" ? getCategoryOptions ( ) . length : LOCALE_OPTIONS . length ;
131+ const optionCount =
132+ step === "category"
133+ ? getCategoryOptions ( currentLocale , currentThinkingLocale , currentReplyLocale ) . length
134+ : LOCALE_OPTIONS . length ;
114135
115136 if ( key . upArrow ) {
116137 setActiveIndex ( ( idx ) => ( idx - 1 + optionCount ) % optionCount ) ;
@@ -143,15 +164,16 @@ const ConfigDropdown: React.FC<Props> = ({
143164
144165 const items =
145166 step === "category"
146- ? getCategoryOptions ( ) . map ( ( option ) => ( {
167+ ? getCategoryOptions ( currentLocale , currentThinkingLocale , currentReplyLocale ) . map ( ( option ) => ( {
147168 key : option . key ,
148169 label : option . label ,
170+ description : option . description ,
149171 selected : false ,
150172 } ) )
151173 : LOCALE_OPTIONS . map ( ( option ) => ( {
152174 key : option . key ,
153- label : option . label ,
154- description : option . key === getCurrentLocaleForCategory ( selectedCategory ! ) ? "current" : "" ,
175+ label : getLocaleDisplayName ( option . key ) ,
176+ description : option . key === getCurrentLocaleForCategory ( selectedCategory ! ) ? t ( "ui.config.currentLabel" ) : "" ,
155177 selected : option . key === getCurrentLocaleForCategory ( selectedCategory ! ) ,
156178 } ) ) ;
157179
0 commit comments