@@ -9,6 +9,8 @@ import { ILauncher } from '@jupyterlab/launcher';
9
9
10
10
import { IMainMenu } from '@jupyterlab/mainmenu' ;
11
11
12
+ import { ITranslator } from '@jupyterlab/translation' ;
13
+
12
14
import { IRenderMimeRegistry } from '@jupyterlab/rendermime' ;
13
15
14
16
import { Menu } from '@lumino/widgets' ;
@@ -31,29 +33,32 @@ const extension: JupyterFrontEndPlugin<void> = {
31
33
id : 'kernel-output' ,
32
34
autoStart : true ,
33
35
optional : [ ILauncher ] ,
34
- requires : [ ICommandPalette , IMainMenu , IRenderMimeRegistry ] ,
36
+ requires : [ ICommandPalette , IMainMenu , IRenderMimeRegistry , ITranslator ] ,
35
37
activate : activate
36
38
} ;
37
39
38
40
/**
39
41
* Activate the JupyterLab extension.
40
42
*
41
- * @param app Jupyter Font End
43
+ * @param app Jupyter Front End
42
44
* @param palette Jupyter Commands Palette
43
45
* @param mainMenu Jupyter Menu
44
46
* @param rendermime Jupyter Render Mime Registry
47
+ * @param translator Jupyter Translator
45
48
* @param launcher [optional] Jupyter Launcher
46
49
*/
47
50
function activate (
48
51
app : JupyterFrontEnd ,
49
52
palette : ICommandPalette ,
50
53
mainMenu : IMainMenu ,
51
54
rendermime : IRenderMimeRegistry ,
55
+ translator : ITranslator ,
52
56
launcher : ILauncher | null
53
57
) : void {
54
58
const manager = app . serviceManager ;
55
59
const { commands, shell } = app ;
56
60
const category = 'Extension Examples' ;
61
+ const trans = translator . load ( 'jupyterlab' ) ;
57
62
58
63
let panel : ExamplePanel ;
59
64
@@ -63,36 +68,36 @@ function activate(
63
68
* @returns The panel
64
69
*/
65
70
async function createPanel ( ) : Promise < ExamplePanel > {
66
- panel = new ExamplePanel ( manager , rendermime ) ;
71
+ panel = new ExamplePanel ( manager , rendermime , translator ) ;
67
72
shell . add ( panel , 'main' ) ;
68
73
return panel ;
69
74
}
70
75
71
76
// add menu tab
72
77
const exampleMenu = new Menu ( { commands } ) ;
73
- exampleMenu . title . label = 'Kernel Output' ;
78
+ exampleMenu . title . label = trans . __ ( 'Kernel Output' ) ;
74
79
mainMenu . addMenu ( exampleMenu ) ;
75
80
76
81
// add commands to registry
77
82
commands . addCommand ( CommandIDs . create , {
78
- label : 'Open the Kernel Output Panel' ,
79
- caption : 'Open the Kernel Output Panel' ,
83
+ label : trans . __ ( 'Open the Kernel Output Panel' ) ,
84
+ caption : trans . __ ( 'Open the Kernel Output Panel' ) ,
80
85
execute : createPanel
81
86
} ) ;
82
87
83
88
commands . addCommand ( CommandIDs . execute , {
84
- label : 'Contact Kernel and Execute Code' ,
85
- caption : 'Contact Kernel and Execute Code' ,
89
+ label : trans . __ ( 'Contact Kernel and Execute Code' ) ,
90
+ caption : trans . __ ( 'Contact Kernel and Execute Code' ) ,
86
91
execute : async ( ) => {
87
92
// Create the panel if it does not exist
88
93
if ( ! panel ) {
89
94
await createPanel ( ) ;
90
95
}
91
96
// Prompt the user about the statement to be executed
92
97
const input = await InputDialog . getText ( {
93
- title : 'Code to execute' ,
94
- okLabel : 'Execute' ,
95
- placeholder : 'Statement to execute'
98
+ title : trans . __ ( 'Code to execute' ) ,
99
+ okLabel : trans . __ ( 'Execute' ) ,
100
+ placeholder : trans . __ ( 'Statement to execute' )
96
101
} ) ;
97
102
// Execute the statement
98
103
if ( input . button . accept ) {
0 commit comments