From fd9577cfbf88829e37aeddd15a72cb3902a43631 Mon Sep 17 00:00:00 2001 From: Alfonso Salces Date: Mon, 22 Jul 2024 09:00:50 +0200 Subject: [PATCH 1/2] MOBILE-4630 pluginfile: Add lang to file download request --- src/core/services/filepool.ts | 1 + src/core/services/lang.ts | 13 +++++++++++++ src/core/services/utils/url.ts | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/core/services/filepool.ts b/src/core/services/filepool.ts index 7f0908419..9455dfbfb 100644 --- a/src/core/services/filepool.ts +++ b/src/core/services/filepool.ts @@ -97,6 +97,7 @@ export class CoreFilepoolProvider { new RegExp('(\\?|&)forcedownload=[0-1]'), new RegExp('(\\?|&)preview=[A-Za-z0-9]+'), new RegExp('(\\?|&)offline=[0-1]', 'g'), + new RegExp(/(\\?|&)lang=[A-Za-z\-_]+/, 'g'), ]; // To handle file downloads using the queue. diff --git a/src/core/services/lang.ts b/src/core/services/lang.ts index 690724c5c..ec7777d3f 100644 --- a/src/core/services/lang.ts +++ b/src/core/services/lang.ts @@ -249,6 +249,19 @@ export class CoreLangProvider { return format ? this.formatLanguage(this.currentLanguage, format) : this.currentLanguage; } + /** + * Get current language sync. + * + * @returns Current language or undefined. + */ + getCurrentLanguageSync(format?: CoreLangFormat): string | undefined { + if (this.currentLanguage === undefined) { + return; + } + + return format ? this.formatLanguage(this.currentLanguage, format) : this.currentLanguage; + } + /** * Update a language code to the given format. * diff --git a/src/core/services/utils/url.ts b/src/core/services/utils/url.ts index a89f37267..e05a8725b 100644 --- a/src/core/services/utils/url.ts +++ b/src/core/services/utils/url.ts @@ -211,7 +211,8 @@ export class CoreUrlUtilsProvider { url = this.addParamsToUrl(url, { token }); } - return this.addParamsToUrl(url, { offline: '1' }); // Always send offline=1 (it's for external repositories). + // Always send offline=1 (it's for external repositories). + return this.addParamsToUrl(url, { offline: '1', lang: CoreLang.getCurrentLanguageSync(CoreLangFormat.LMS) }); } /** From 001fba65cb9d2cb67cfb44972ac3678b640b4d6e Mon Sep 17 00:00:00 2001 From: Alfonso Salces Date: Mon, 22 Jul 2024 09:17:07 +0200 Subject: [PATCH 2/2] MOBILE-4630 dom: Use multilang filter in showDeleteConfirm --- src/core/services/utils/dom.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/services/utils/dom.ts b/src/core/services/utils/dom.ts index 3ea323352..f41dd5961 100644 --- a/src/core/services/utils/dom.ts +++ b/src/core/services/utils/dom.ts @@ -934,14 +934,15 @@ export class CoreDomUtilsProvider { * @param options More options. See https://ionicframework.com/docs/v3/api/components/alert/AlertController/ * @returns Promise resolved if the user confirms and rejected with a canceled error if he cancels. */ - showDeleteConfirm( + async showDeleteConfirm( translateMessage: string = 'core.areyousure', translateArgs: Record = {}, options: AlertOptions = {}, ): Promise { - return new Promise((resolve, reject): void => { - options.message = Translate.instant(translateMessage, translateArgs); + options.message = Translate.instant(translateMessage, translateArgs); + options.message = await CoreLang.filterMultilang(options.message); + return new Promise((resolve, reject): void => { options.buttons = [ { text: Translate.instant('core.cancel'),