11import { ChatWidget } from '@jupyter/chat' ;
22import { IDisposable } from '@lumino/disposable' ;
3+ import type { TranslationBundle } from '@jupyterlab/translation' ;
34import { AIChatModel } from './chat-model' ;
45
56export class ApprovalButtons implements IDisposable {
67 constructor ( options : ApprovalButtons . IOptions ) {
78 this . _chatPanel = options . chatPanel ;
89 this . _chatModel = this . _chatPanel . model as AIChatModel ;
10+ this . _trans = options . trans ;
911
1012 // Set up approval button event handling
1113 this . _setupApprovalHandlers ( ) ;
@@ -201,7 +203,9 @@ export class ApprovalButtons implements IDisposable {
201203 icon . textContent = isApprove ? '✅' : '❌' ;
202204
203205 const text = document . createElement ( 'span' ) ;
204- text . textContent = isApprove ? 'Tools approved' : 'Tools rejected' ;
206+ text . textContent = isApprove
207+ ? this . _trans . __ ( 'Tools approved' )
208+ : this . _trans . __ ( 'Tools rejected' ) ;
205209
206210 statusDiv . appendChild ( icon ) ;
207211 statusDiv . appendChild ( text ) ;
@@ -230,7 +234,9 @@ export class ApprovalButtons implements IDisposable {
230234 icon . textContent = isApprove ? '✅' : '❌' ;
231235
232236 const text = document . createElement ( 'span' ) ;
233- text . textContent = isApprove ? 'Tools approved' : 'Tools rejected' ;
237+ text . textContent = isApprove
238+ ? this . _trans . __ ( 'Tools approved' )
239+ : this . _trans . __ ( 'Tools rejected' ) ;
234240
235241 statusDiv . appendChild ( icon ) ;
236242 statusDiv . appendChild ( text ) ;
@@ -346,8 +352,14 @@ export class ApprovalButtons implements IDisposable {
346352 buttonContainer . setAttribute ( 'data-message-id' , messageId ) ;
347353 }
348354
349- const approveBtn = this . _createApprovalButton ( 'Approve' , true ) ;
350- const rejectBtn = this . _createApprovalButton ( 'Reject' , false ) ;
355+ const approveBtn = this . _createApprovalButton (
356+ this . _trans . __ ( 'Approve' ) ,
357+ true
358+ ) ;
359+ const rejectBtn = this . _createApprovalButton (
360+ this . _trans . __ ( 'Reject' ) ,
361+ false
362+ ) ;
351363
352364 // Add click handlers directly to the buttons
353365 this . _addButtonHandler ( approveBtn ) ;
@@ -388,12 +400,12 @@ export class ApprovalButtons implements IDisposable {
388400 }
389401
390402 const approveBtn = this . _createApprovalButton (
391- 'Approve' ,
403+ this . _trans . __ ( 'Approve' ) ,
392404 true ,
393405 'jp-ai-group-approve-all'
394406 ) ;
395407 const rejectBtn = this . _createApprovalButton (
396- 'Reject' ,
408+ this . _trans . __ ( 'Reject' ) ,
397409 false ,
398410 'jp-ai-group-reject-all'
399411 ) ;
@@ -443,6 +455,7 @@ export class ApprovalButtons implements IDisposable {
443455 private _chatModel : AIChatModel ;
444456 private _isDisposed : boolean = false ;
445457 private _mutationObserver ?: MutationObserver ;
458+ private _trans : TranslationBundle ;
446459}
447460
448461/**
@@ -457,5 +470,9 @@ export namespace ApprovalButtons {
457470 * The chat panel widget to wrap.
458471 */
459472 chatPanel : ChatWidget ;
473+ /**
474+ * The application language translation bundle.
475+ */
476+ trans : TranslationBundle ;
460477 }
461478}
0 commit comments