Skip to content

Commit f5bd8a7

Browse files
committed
translator
1 parent f26319a commit f5bd8a7

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"@jupyterlab/coreutils": "^6.4.2",
5858
"@jupyterlab/services": "^7.4.2",
5959
"@jupyterlab/settingregistry": "^4.4.2",
60+
"@jupyterlab/translation": "^4.4.2",
6061
"@jupyterlite/services": "^0.7.0",
6162
"@lumino/signaling": "^2.1.5",
6263
"mock-socket": "^9.3.1"

src/dialogs.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Dialog } from '@jupyterlab/apputils';
2+
import type { TranslationBundle } from '@jupyterlab/translation';
23
import { Widget } from '@lumino/widgets';
34

45
/**
@@ -65,13 +66,15 @@ export class RemoteServerConfigBody
6566
super();
6667
this.addClass('jp-HybridKernels-configDialog');
6768

69+
const trans = options.trans;
70+
6871
// Full URL input section
6972
const fullUrlSection = document.createElement('div');
7073
fullUrlSection.className = 'jp-HybridKernels-formSection';
7174

7275
const fullUrlLabel = document.createElement('label');
7376
fullUrlLabel.className = 'jp-HybridKernels-label';
74-
fullUrlLabel.textContent = 'Paste Full URL (with token)';
77+
fullUrlLabel.textContent = trans.__('Paste Full URL (with token)');
7578
fullUrlLabel.htmlFor = 'hybrid-kernels-full-url';
7679
fullUrlSection.appendChild(fullUrlLabel);
7780

@@ -85,8 +88,9 @@ export class RemoteServerConfigBody
8588

8689
const fullUrlHelp = document.createElement('small');
8790
fullUrlHelp.className = 'jp-HybridKernels-help';
88-
fullUrlHelp.textContent =
89-
'Paste a full JupyterHub/Binder URL to auto-fill the fields below';
91+
fullUrlHelp.textContent = trans.__(
92+
'Paste a full JupyterHub/Binder URL to auto-fill the fields below'
93+
);
9094
fullUrlSection.appendChild(fullUrlHelp);
9195

9296
this.node.appendChild(fullUrlSection);
@@ -102,7 +106,7 @@ export class RemoteServerConfigBody
102106

103107
const serverUrlLabel = document.createElement('label');
104108
serverUrlLabel.className = 'jp-HybridKernels-label';
105-
serverUrlLabel.textContent = 'Server URL';
109+
serverUrlLabel.textContent = trans.__('Server URL');
106110
serverUrlLabel.htmlFor = 'hybrid-kernels-server-url';
107111
serverUrlSection.appendChild(serverUrlLabel);
108112

@@ -122,15 +126,15 @@ export class RemoteServerConfigBody
122126

123127
const tokenLabel = document.createElement('label');
124128
tokenLabel.className = 'jp-HybridKernels-label';
125-
tokenLabel.textContent = 'Authentication Token';
129+
tokenLabel.textContent = trans.__('Authentication Token');
126130
tokenLabel.htmlFor = 'hybrid-kernels-token';
127131
tokenSection.appendChild(tokenLabel);
128132

129133
this._tokenInput = document.createElement('input');
130134
this._tokenInput.type = 'password';
131135
this._tokenInput.id = 'hybrid-kernels-token';
132136
this._tokenInput.className = 'jp-mod-styled jp-HybridKernels-input';
133-
this._tokenInput.placeholder = 'Enter token (optional)';
137+
this._tokenInput.placeholder = trans.__('Enter token (optional)');
134138
this._tokenInput.value = options.token;
135139
tokenSection.appendChild(this._tokenInput);
136140

@@ -189,5 +193,10 @@ export namespace RemoteServerConfigBody {
189193
* The initial token value.
190194
*/
191195
token: string;
196+
197+
/**
198+
* The translation bundle.
199+
*/
200+
trans: TranslationBundle;
192201
}
193202
}

src/index.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import {
2424

2525
import { URLExt } from '@jupyterlab/coreutils';
2626

27+
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
28+
2729
import { linkIcon } from '@jupyterlab/ui-components';
2830

2931
import { Widget } from '@lumino/widgets';
@@ -155,14 +157,18 @@ const configDialogPlugin: JupyterFrontEndPlugin<void> = {
155157
description: 'Provides a dialog to configure the remote server',
156158
autoStart: true,
157159
requires: [IRemoteServerConfig, IKernelSpecManager, IToolbarWidgetRegistry],
158-
optional: [ICommandPalette],
160+
optional: [ICommandPalette, ITranslator],
159161
activate: (
160162
app: JupyterFrontEnd,
161163
remoteConfig: IRemoteServerConfig,
162164
kernelSpecManager: KernelSpec.IManager,
163165
toolbarRegistry: IToolbarWidgetRegistry,
164-
palette: ICommandPalette | null
166+
palette: ICommandPalette | null,
167+
translator: ITranslator | null
165168
): void => {
169+
const trans = (translator ?? nullTranslator).load(
170+
'jupyterlab_hybrid_kernels'
171+
);
166172
const isRemoteMode = getHybridKernelsMode() === 'remote';
167173

168174
if (isRemoteMode) {
@@ -176,20 +182,24 @@ const configDialogPlugin: JupyterFrontEndPlugin<void> = {
176182
}
177183

178184
app.commands.addCommand(CommandIds.configureRemoteServer, {
179-
label: 'Configure Remote Jupyter Server',
180-
caption: 'Configure the remote Jupyter server connection',
185+
label: trans.__('Configure Remote Jupyter Server'),
186+
caption: trans.__('Configure the remote Jupyter server connection'),
181187
icon: linkIcon,
182188
isVisible: () => isRemoteMode,
183189
execute: async () => {
184190
const body = new RemoteServerConfigBody({
185191
baseUrl: remoteConfig.baseUrl,
186-
token: remoteConfig.token
192+
token: remoteConfig.token,
193+
trans
187194
});
188195

189196
const result = await showDialog({
190-
title: 'Remote Server Configuration',
197+
title: trans.__('Remote Server Configuration'),
191198
body,
192-
buttons: [Dialog.cancelButton(), Dialog.okButton({ label: 'Save' })],
199+
buttons: [
200+
Dialog.cancelButton(),
201+
Dialog.okButton({ label: trans.__('Save') })
202+
],
193203
focusNodeSelector: 'input'
194204
});
195205

@@ -223,7 +233,7 @@ const configDialogPlugin: JupyterFrontEndPlugin<void> = {
223233
if (palette) {
224234
palette.addItem({
225235
command: CommandIds.configureRemoteServer,
226-
category: 'Kernel'
236+
category: trans.__('Kernel')
227237
});
228238
}
229239
}

0 commit comments

Comments
 (0)