diff --git a/packages/collaboration-extension/src/filebrowser.ts b/packages/collaboration-extension/src/filebrowser.ts index 60dcfdb4..000ee55d 100644 --- a/packages/collaboration-extension/src/filebrowser.ts +++ b/packages/collaboration-extension/src/filebrowser.ts @@ -9,6 +9,7 @@ import { IDefaultFileBrowser, IFileBrowserFactory } from '@jupyterlab/filebrowser'; +import { ITranslator } from '@jupyterlab/translation'; import { CommandRegistry } from '@lumino/commands'; @@ -27,11 +28,12 @@ namespace CommandIDs { export const defaultFileBrowser: JupyterFrontEndPlugin = { id: '@jupyter/collaboration-extension:defaultFileBrowser', provides: IDefaultFileBrowser, - requires: [IFileBrowserFactory], + requires: [IFileBrowserFactory, ITranslator], optional: [IRouter, JupyterFrontEnd.ITreeResolver, ILabShell], activate: async ( app: JupyterFrontEnd, fileBrowserFactory: IFileBrowserFactory, + translator: ITranslator, router: IRouter | null, tree: JupyterFrontEnd.ITreeResolver | null, labShell: ILabShell | null @@ -41,7 +43,8 @@ export const defaultFileBrowser: JupyterFrontEndPlugin = { ); const { commands } = app; - const drive = new YDrive(app.serviceManager.user); + const trans = translator.load('jupyter_collaboration'); + const drive = new YDrive(app.serviceManager.user, trans); app.serviceManager.contents.addDrive(drive); // Manually restore and load the default file browser. diff --git a/packages/docprovider/src/ydrive.ts b/packages/docprovider/src/ydrive.ts index d42884de..79c200dc 100644 --- a/packages/docprovider/src/ydrive.ts +++ b/packages/docprovider/src/ydrive.ts @@ -9,6 +9,7 @@ import { YNotebook } from '@jupyter/ydoc'; import { URLExt } from '@jupyterlab/coreutils'; +import { TranslationBundle } from '@jupyterlab/translation'; import { Contents, Drive, User } from '@jupyterlab/services'; import { WebSocketProvider } from './yprovider'; @@ -27,9 +28,10 @@ export class YDrive extends Drive { * * @param user - The user manager to add the identity to the awareness of documents. */ - constructor(user: User.IManager) { + constructor(user: User.IManager, translator: TranslationBundle) { super({ name: 'YDrive' }); this._user = user; + this._translator = translator; this._providers = new Map(); this.sharedModelFactory = new SharedModelFactory(this._onCreate); @@ -155,7 +157,8 @@ export class YDrive extends Drive { format: options.format, contentType: options.contentType, model: sharedModel, - user: this._user + user: this._user, + translator: this._translator }); const key = `${options.contentType}:${options.format}:${options.path}`; @@ -178,6 +181,7 @@ export class YDrive extends Drive { }; private _user: User.IManager; + private _translator: TranslationBundle; private _providers: Map; } diff --git a/packages/docprovider/src/yprovider.ts b/packages/docprovider/src/yprovider.ts index bd34a576..c742eb9c 100644 --- a/packages/docprovider/src/yprovider.ts +++ b/packages/docprovider/src/yprovider.ts @@ -6,6 +6,7 @@ import { URLExt } from '@jupyterlab/coreutils'; import { showErrorMessage, Dialog } from '@jupyterlab/apputils'; import { ServerConnection, User } from '@jupyterlab/services'; +import { TranslationBundle } from '@jupyterlab/translation'; import { PromiseDelegate } from '@lumino/coreutils'; import { IDisposable } from '@lumino/disposable'; @@ -53,6 +54,7 @@ export class WebSocketProvider implements IDocumentProvider { this._sharedModel = options.model; this._awareness = options.model.awareness; this._yWebsocketProvider = null; + this._translator = options.translator; const user = options.user; @@ -133,9 +135,11 @@ export class WebSocketProvider implements IDocumentProvider { console.error('Document provider closed:', event.reason); showErrorMessage( - 'Session expired', - 'The document session expired. We need to reload this browser tab.', - [Dialog.okButton()] + this._translator.__('Session expired'), + this._translator.__( + 'The document session expired. You need to reload this browser tab.' + ), + [Dialog.okButton({ label: this._translator.__('Reload') })] ) .then(r => window.location.reload()) .catch(e => window.location.reload()); @@ -154,6 +158,7 @@ export class WebSocketProvider implements IDocumentProvider { private _serverUrl: string; private _sharedModel: YDocument; private _yWebsocketProvider: YWebsocketProvider | null; + private _translator: TranslationBundle; } /** @@ -193,5 +198,10 @@ export namespace WebSocketProvider { * The user data */ user: User.IManager; + + /** + * The jupyterlab translator + */ + translator: TranslationBundle; } }