From 36e36d8faadcc90c89d1178b5c7ba6af4f14ee7a Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 18 Apr 2022 20:16:27 +0300 Subject: [PATCH] [Mobile] Fix translation on loading (open as anonymous) --- .../mobile/src/controller/Main.jsx | 35 +++++++++++++------ .../mobile/src/controller/Main.jsx | 22 ++++++++---- .../mobile/src/controller/Main.jsx | 25 ++++++++----- 3 files changed, 56 insertions(+), 26 deletions(-) diff --git a/apps/documenteditor/mobile/src/controller/Main.jsx b/apps/documenteditor/mobile/src/controller/Main.jsx index 6d06f301a..4865fb0e9 100644 --- a/apps/documenteditor/mobile/src/controller/Main.jsx +++ b/apps/documenteditor/mobile/src/controller/Main.jsx @@ -80,8 +80,8 @@ class MainController extends Component { }; const loadConfig = data => { - const _t = this._t; - + const { t } = this.props; + const _t = t('Main', {returnObjects:true}); EditorUIController.isSupportEditFeature(); this.editorConfig = Object.assign({}, this.editorConfig, data.config); @@ -177,13 +177,15 @@ class MainController extends Component { const onEditorPermissions = params => { const licType = params.asc_getLicenseType(); + const { t } = this.props; + const _t = t('Main', {returnObjects:true}); // check licType if (Asc.c_oLicenseResult.Expired === licType || Asc.c_oLicenseResult.Error === licType || Asc.c_oLicenseResult.ExpiredTrial === licType) { f7.dialog.create({ - title : this._t.titleLicenseExp, - text : this._t.warnLicenseExp + title : _t.titleLicenseExp, + text : _t.warnLicenseExp }).open(); return; } @@ -403,7 +405,9 @@ class MainController extends Component { this.api.asc_continueSaving(); }, 500); - return this._t.leavePageText; + const { t } = this.props; + const _t = t('Main', {returnObjects:true}); + return _t.leavePageText; } } @@ -520,7 +524,8 @@ class MainController extends Component { onServerVersion (buildVersion) { if (this.changeServerVersion) return true; - const _t = this._t; + const { t } = this.props; + const _t = t('Main', {returnObjects:true}); if (About.appVersion() !== buildVersion && !About.compareVersions()) { this.changeServerVersion = true; @@ -791,7 +796,9 @@ class MainController extends Component { this.api.asc_OnSaveEnd(data.result); if (data && data.result === false) { - const _t = this._t; + const { t } = this.props; + const _t = t('Main', {returnObjects:true}); + f7.dialog.alert( (!data.message) ? _t.errorProcessSaveResult : data.message, _t.criticalErrorTitle @@ -808,7 +815,9 @@ class MainController extends Component { Common.Notifications.trigger('api:disconnect'); if (!old_rights) { - const _t = this._t; + const { t } = this.props; + const _t = t('Main', {returnObjects:true}); + f7.dialog.alert( (!data.message) ? _t.warnProcessRightsChange : data.message, _t.notcriticalErrorTitle, @@ -821,7 +830,9 @@ class MainController extends Component { onDownloadAs () { const appOptions = this.props.storeAppOptions; if ( !appOptions.canDownload && !appOptions.canDownloadOrigin) { - Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, this._t.errorAccessDeny); + const { t } = this.props; + const _t = t('Main', {returnObjects:true}); + Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, _t.errorAccessDeny); return; } @@ -848,7 +859,8 @@ class MainController extends Component { } onUpdateVersion (callback) { - const _t = this._t; + const { t } = this.props; + const _t = t('Main', {returnObjects:true}); this.needToUpdateVersion = true; Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], this.LoadingDocument); @@ -940,7 +952,8 @@ class MainController extends Component { if (value === 1) { this.api.asc_runAutostartMacroses(); } else if (value === 0) { - const _t = this._t; + const { t } = this.props; + const _t = t('Main', {returnObjects:true}); f7.dialog.create({ title: _t.notcriticalErrorTitle, text: _t.textHasMacros, diff --git a/apps/presentationeditor/mobile/src/controller/Main.jsx b/apps/presentationeditor/mobile/src/controller/Main.jsx index cd4bb85da..64508434b 100644 --- a/apps/presentationeditor/mobile/src/controller/Main.jsx +++ b/apps/presentationeditor/mobile/src/controller/Main.jsx @@ -73,7 +73,8 @@ class MainController extends Component { }; const loadConfig = data => { - const _t = this._t; + const { t } = this.props; + const _t = t('Controller.Main', {returnObjects:true}); EditorUIController.isSupportEditFeature(); @@ -284,7 +285,9 @@ class MainController extends Component { this.api.asc_continueSaving(); }, 500); - return this._t.leavePageText; + const { t } = this.props; + const _t = t('Controller.Main', {returnObjects:true}); + return _t.leavePageText; } } @@ -592,7 +595,8 @@ class MainController extends Component { } onUpdateVersion (callback) { - const _t = this._t; + const { t } = this.props; + const _t = t('Controller.Main', {returnObjects:true}); this.needToUpdateVersion = true; Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], this.LoadingDocument); @@ -611,7 +615,8 @@ class MainController extends Component { onServerVersion (buildVersion) { if (this.changeServerVersion) return true; - const _t = this._t; + const { t } = this.props; + const _t = t('Controller.Main', {returnObjects:true}); if (About.appVersion() !== buildVersion && !window.compareVersions) { this.changeServerVersion = true; @@ -759,7 +764,8 @@ class MainController extends Component { if (value === 1) { this.api.asc_runAutostartMacroses(); } else if (value === 0) { - const _t = this._t; + const { t } = this.props; + const _t = t('Controller.Main', {returnObjects:true}); f7.dialog.create({ title: _t.notcriticalErrorTitle, text: _t.textHasMacros, @@ -801,7 +807,8 @@ class MainController extends Component { this.api.asc_OnSaveEnd(data.result); if (data && data.result === false) { - const _t = this._t; + const { t } = this.props; + const _t = t('Controller.Main', {returnObjects:true}); f7.dialog.alert( (!data.message) ? _t.errorProcessSaveResult : data.message, _t.criticalErrorTitle @@ -818,7 +825,8 @@ class MainController extends Component { Common.Notifications.trigger('api:disconnect'); if (!old_rights) { - const _t = this._t; + const { t } = this.props; + const _t = t('Controller.Main', {returnObjects:true}); f7.dialog.alert( (!data.message) ? _t.warnProcessRightsChange : data.message, _t.notcriticalErrorTitle, diff --git a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx index 43317069e..cfd1f6385 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx @@ -91,7 +91,8 @@ class MainController extends Component { }; const loadConfig = data => { - const _t = this._t; + const { t } = this.props; + const _t = t('Controller.Main', {returnObjects:true}); EditorUIController.isSupportEditFeature(); @@ -735,7 +736,8 @@ class MainController extends Component { if (value === 1) { this.api.asc_runAutostartMacroses(); } else if (value === 0) { - const _t = this._t; + const { t } = this.props; + const _t = t('Controller.Main', {returnObjects:true}); f7.dialog.create({ title: _t.notcriticalErrorTitle, text: _t.textHasMacros, @@ -782,7 +784,8 @@ class MainController extends Component { } onBeforeUnload () { - const _t = this._t; + const { t } = this.props; + const _t = t('Controller.Main', {returnObjects:true}); LocalStorage.save(); @@ -804,7 +807,8 @@ class MainController extends Component { } onUpdateVersion (callback) { - const _t = this._t; + const { t } = this.props; + const _t = t('Controller.Main', {returnObjects:true}); this.needToUpdateVersion = true; Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], this.LoadingDocument); @@ -823,7 +827,8 @@ class MainController extends Component { onServerVersion (buildVersion) { if (this.changeServerVersion) return true; - const _t = this._t; + const { t } = this.props; + const _t = t('Controller.Main', {returnObjects:true}); if (About.appVersion() !== buildVersion && !About.compareVersions()) { this.changeServerVersion = true; @@ -909,7 +914,8 @@ class MainController extends Component { this.api.asc_OnSaveEnd(data.result); if (data && data.result === false) { - const _t = this._t; + const { t } = this.props; + const _t = t('Controller.Main', {returnObjects:true}); f7.dialog.alert( (!data.message) ? _t.errorProcessSaveResult : data.message, _t.criticalErrorTitle @@ -926,7 +932,8 @@ class MainController extends Component { Common.Notifications.trigger('api:disconnect'); if (!old_rights) { - const _t = this._t; + const { t } = this.props; + const _t = t('Controller.Main', {returnObjects:true}); f7.dialog.alert( (!data.message) ? _t.warnProcessRightsChange : data.message, _t.notcriticalErrorTitle, @@ -938,7 +945,9 @@ class MainController extends Component { onDownloadAs () { if ( this.props.storeAppOptions.canDownload) { - Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, this._t.errorAccessDeny); + const { t } = this.props; + const _t = t('Controller.Main', {returnObjects:true}); + Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, _t.errorAccessDeny); return; } this._state.isFromGatewayDownloadAs = true;