Skip to content

Commit bd8b942

Browse files
committed
Add translation
1 parent f9f6fab commit bd8b942

File tree

4 files changed

+34
-18
lines changed

4 files changed

+34
-18
lines changed

packages/collaboration-extension/src/collaboration.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ export const rtcPanelPlugin: JupyterFrontEndPlugin<void> = {
151151
userPanel.addClass('jp-RTCPanel');
152152
app.shell.add(userPanel, 'left', { rank: 300 });
153153

154-
const currentUserPanel = new UserInfoPanel(user);
154+
const currentUserPanel = new UserInfoPanel({
155+
userManager: user,
156+
translation: trans
157+
});
155158
currentUserPanel.title.label = trans.__('User info');
156159
currentUserPanel.title.caption = trans.__('User information');
157160
userPanel.addWidget(currentUserPanel);

packages/collaboration/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"@jupyterlab/apputils": "^4.4.0",
4545
"@jupyterlab/coreutils": "^6.4.0",
4646
"@jupyterlab/docregistry": "^4.4.0",
47+
"@jupyterlab/rendermime-interfaces": "^3.12.0",
4748
"@jupyterlab/services": "^7.4.0",
4849
"@jupyterlab/ui-components": "^4.4.0",
4950
"@lumino/coreutils": "^2.2.1",

packages/collaboration/src/userinfopanel.tsx

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,48 @@ import { Dialog, ReactWidget, showDialog } from '@jupyterlab/apputils';
55

66
import { ServerConnection, User } from '@jupyterlab/services';
77

8+
import { URLExt } from '@jupyterlab/coreutils';
9+
10+
import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
11+
812
import { Panel } from '@lumino/widgets';
913

1014
import * as React from 'react';
1115

1216
import { UserDetailsBody, UserIconComponent } from './components';
13-
import { URLExt } from '@jupyterlab/coreutils';
17+
18+
/**
19+
* The properties for the UserInfoBody.
20+
*/
21+
type UserInfoProps = {
22+
userManager: User.IManager;
23+
translation: IRenderMime.TranslationBundle;
24+
};
1425

1526
export class UserInfoPanel extends Panel {
1627
private _profile: User.IManager;
1728
private _body: UserInfoBody | null;
1829

19-
constructor(user: User.IManager) {
30+
constructor(options: UserInfoProps) {
2031
super({});
2132
this.addClass('jp-UserInfoPanel');
22-
23-
this._profile = user;
33+
this._profile = options.userManager;
2434
this._body = null;
2535

2636
if (this._profile.isReady) {
27-
this._body = new UserInfoBody({ userManager: this._profile });
37+
this._body = new UserInfoBody({
38+
userManager: this._profile,
39+
translation: options.translation
40+
});
2841
this.addWidget(this._body);
2942
this.update();
3043
} else {
3144
this._profile.ready
3245
.then(() => {
33-
this._body = new UserInfoBody({ userManager: this._profile });
46+
this._body = new UserInfoBody({
47+
userManager: this._profile,
48+
translation: options.translation
49+
});
3450
this.addWidget(this._body);
3551
this.update();
3652
})
@@ -39,13 +55,6 @@ export class UserInfoPanel extends Panel {
3955
}
4056
}
4157

42-
/**
43-
* The properties for the UserInfoBody.
44-
*/
45-
type UserInfoBodyProps = {
46-
userManager: User.IManager;
47-
};
48-
4958
/**
5059
* A SettingsWidget for the user.
5160
*/
@@ -54,13 +63,14 @@ export class UserInfoBody
5463
implements Dialog.IBodyWidget<User.IManager>
5564
{
5665
private _userManager: User.IManager;
57-
66+
private _translation: IRenderMime.TranslationBundle;
5867
/**
5968
* Constructs a new settings widget.
6069
*/
61-
constructor(props: UserInfoBodyProps) {
70+
constructor(props: UserInfoProps) {
6271
super();
6372
this._userManager = props.userManager;
73+
this._translation = props.translation;
6474
}
6575

6676
get user(): User.IManager {
@@ -80,7 +90,7 @@ export class UserInfoBody
8090
body: new UserDetailsBody({
8191
userManager: this._userManager
8292
}),
83-
title: 'User Details'
93+
title: this._translation.__('User Details')
8494
}).then(async result => {
8595
if (result.button.accept) {
8696
// Call the Jupyter Server API to update the user field
@@ -100,7 +110,8 @@ export class UserInfoBody
100110
}
101111

102112
if (!response.ok) {
103-
throw new Error('Failed to update user data');
113+
const errorMsg = this._translation.__('Failed to update user data');
114+
throw new Error(errorMsg);
104115
}
105116

106117
// Refresh user information

yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,6 +2112,7 @@ __metadata:
21122112
"@jupyterlab/apputils": ^4.4.0
21132113
"@jupyterlab/coreutils": ^6.4.0
21142114
"@jupyterlab/docregistry": ^4.4.0
2115+
"@jupyterlab/rendermime-interfaces": ^3.12.0
21152116
"@jupyterlab/services": ^7.4.0
21162117
"@jupyterlab/ui-components": ^4.4.0
21172118
"@lumino/coreutils": ^2.2.1

0 commit comments

Comments
 (0)