44 */
55
66import { IDocumentManager } from '@jupyterlab/docmanager' ;
7+ import {
8+ ITranslator ,
9+ nullTranslator ,
10+ TranslationBundle
11+ } from '@jupyterlab/translation' ;
712import { ArrayExt } from '@lumino/algorithm' ;
813import { CommandRegistry } from '@lumino/commands' ;
914import { PromiseDelegate } from '@lumino/coreutils' ;
1015import { IDisposable } from '@lumino/disposable' ;
1116import { ISignal , Signal } from '@lumino/signaling' ;
1217
1318import { IActiveCellManager } from './active-cell-manager' ;
19+ import { TRANSLATION_DOMAIN } from './context' ;
1420import { IInputModel , InputModel } from './input-model' ;
1521import { Message } from './message' ;
1622import { ISelectionWatcher } from './selection-watcher' ;
@@ -237,6 +243,10 @@ export abstract class AbstractChatModel implements IChatModel {
237243 ...config
238244 } ;
239245
246+ this . _trans = ( options . translator ?? nullTranslator ) . load (
247+ TRANSLATION_DOMAIN
248+ ) ;
249+
240250 this . _inputModel = new InputModel ( {
241251 activeCellManager : options . activeCellManager ,
242252 selectionWatcher : options . selectionWatcher ,
@@ -695,14 +705,24 @@ export abstract class AbstractChatModel implements IChatModel {
695705 this . _commands
696706 . execute ( 'apputils:update-notification' , {
697707 id : this . _notificationId ,
698- message : `${ unreadCount } incoming message(s) ${ this . _name ? 'in ' + this . _name : '' } `
708+ message : this . _name
709+ ? this . _trans . __ (
710+ '%1 incoming message(s) in %2' ,
711+ unreadCount ,
712+ this . _name
713+ )
714+ : this . _trans . __ ( '%1 incoming message(s)' , unreadCount )
699715 } )
700716 . then ( success => {
701717 // Create a new notification only if messages are added.
702718 if ( ! success && canCreate ) {
703719 this . _commands ! . execute ( 'apputils:notify' , {
704720 type : 'info' ,
705- message : `${ unreadCount } incoming message(s) in ${ this . _name } `
721+ message : this . _trans . __ (
722+ '%1 incoming message(s) in %2' ,
723+ unreadCount ,
724+ this . _name
725+ )
706726 } ) . then ( id => {
707727 this . _notificationId = id ;
708728 } ) ;
@@ -725,6 +745,7 @@ export abstract class AbstractChatModel implements IChatModel {
725745 private _id : string | undefined ;
726746 private _name : string = '' ;
727747 private _config : IConfig ;
748+ protected _trans : TranslationBundle ;
728749 private _readyDelegate = new PromiseDelegate < void > ( ) ;
729750 private _inputModel : IInputModel ;
730751 private _disposed = new Signal < this, void > ( this ) ;
@@ -770,6 +791,11 @@ export namespace IChatModel {
770791 */
771792 commands ?: CommandRegistry ;
772793
794+ /**
795+ * The translator for internationalization.
796+ */
797+ translator ?: ITranslator ;
798+
773799 /**
774800 * Active cell manager.
775801 */
0 commit comments