@@ -17,6 +17,7 @@ import type {
1717 TranslateCommandParams ,
1818 TranslateCommandResult ,
1919} from '@js/common/ai-integration' ;
20+ import localizationMessage from '@js/common/core/localization/message' ;
2021import type {
2122 AIChangeStyleOption ,
2223 AIChangeToneOption ,
@@ -75,15 +76,25 @@ export type AICommandExecutor<T extends AICommandNameExtended> = (
7576 callbacks : RequestCallbacks < AICommandResultMap [ T ] > ,
7677) => ( ) => void ;
7778
78- export const defaultCommandNames : Record < AICommandName , string > = {
79- summarize : 'Summarize' ,
80- proofread : 'Proofread' ,
81- expand : 'Expand' ,
82- shorten : 'Shorten' ,
83- changeStyle : 'Change Style' ,
84- changeTone : 'Change Tone' ,
85- translate : 'Translate' ,
86- askAI : 'Ask AI' ,
79+ export const commandMessageKeys : Record < AICommandName , string > = {
80+ summarize : 'dxHtmlEditor-aiCommandSummarize' ,
81+ proofread : 'dxHtmlEditor-aiCommandProofread' ,
82+ expand : 'dxHtmlEditor-aiCommandExpand' ,
83+ shorten : 'dxHtmlEditor-aiCommandShorten' ,
84+ changeStyle : 'dxHtmlEditor-aiCommandChangeStyle' ,
85+ changeTone : 'dxHtmlEditor-aiCommandChangeTone' ,
86+ translate : 'dxHtmlEditor-aiCommandTranslate' ,
87+ askAI : 'dxHtmlEditor-aiCommandAskAI' ,
88+ } ;
89+
90+ export const getDefaultCommandName = ( name : AICommandNameExtended ) : string => {
91+ const key = commandMessageKeys [ name ] ;
92+
93+ if ( key ) {
94+ return localizationMessage . format ( key ) ;
95+ }
96+
97+ return capitalize ( name ) ;
8798} ;
8899
89100const htmlEditorAIChangeStyleOptions : AIChangeStyleOption [ ] = [
@@ -114,21 +125,29 @@ const aiCommandNames = {
114125
115126export type AICommandNameEnum = typeof aiCommandNames [ keyof typeof aiCommandNames ] ;
116127
128+ const getLocalizedCommandOption = ( command : AICommandNameExtended ) : (
129+ option : AIChangeStyleOption | AIChangeToneOption | AITranslateOption
130+ ) => string => (
131+ option : AIChangeStyleOption | AIChangeToneOption | AITranslateOption ,
132+ ) : string => localizationMessage . format ( `dxHtmlEditor-aiCommand${ capitalize ( command ) } ${ capitalize ( option ) } ` ) ;
133+
117134export const getDefaultOptionsByCommand = (
118135 command : AICommandNameExtended ,
119- ) : CommandOption [ ] | undefined => {
120- const commandToOptionsMap : Record < string , CommandOption [ ] > = {
121- changeStyle : htmlEditorAIChangeStyleOptions ,
122- changeTone : htmlEditorAIChangeToneOptions ,
123- translate : htmlEditorAITranslateOptions ,
136+ ) : string [ ] | undefined => {
137+ const getLocalizedOption = getLocalizedCommandOption ( command ) ;
138+
139+ const commandToOptionsMap : Record < string , string [ ] > = {
140+ changeStyle : htmlEditorAIChangeStyleOptions . map ( getLocalizedOption ) ,
141+ changeTone : htmlEditorAIChangeToneOptions . map ( getLocalizedOption ) ,
142+ translate : htmlEditorAITranslateOptions . map ( getLocalizedOption ) ,
124143 } ;
125144
126145 return commandToOptionsMap [ command ] ;
127146} ;
128147
129148const createDefinitionFromString = ( commandName : AICommandName ) : CommandDefinition => {
130- const text = defaultCommandNames [ commandName ] ?? capitalize ( commandName ) ;
131- const defaultOptions = getDefaultOptionsByCommand ( commandName ) ?. map ( capitalize ) ;
149+ const text = getDefaultCommandName ( commandName ) ;
150+ const defaultOptions = getDefaultOptionsByCommand ( commandName ) ;
132151
133152 return {
134153 id : commandName ,
@@ -146,8 +165,8 @@ const createDefinitionFromObject = (
146165 prompt ?: ( param ?: string ) => string ,
147166) : CommandDefinition => {
148167 const capitalizedRaw = rawOptions ?. map ( capitalize ) ;
149- const options = capitalizedRaw ?? getDefaultOptionsByCommand ( name ) ?. map ( capitalize ) ;
150- const displayText = text ?? defaultCommandNames [ name ] ?? capitalize ( name ) ;
168+ const options = capitalizedRaw ?? getDefaultOptionsByCommand ( name ) ;
169+ const displayText = text ?? getDefaultCommandName ( name ) ;
151170
152171 const definition = {
153172 id,
0 commit comments