Merge pull request #4124 from alfonso-salces/MOBILE-4630

MOBILE-4630 pluginfile: Add lang to file download request
main
Dani Palou 2024-07-23 10:02:19 +02:00 committed by GitHub
commit d6b4febe65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 4 deletions

View File

@ -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.

View File

@ -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.
*

View File

@ -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<string, unknown> = {},
options: AlertOptions = {},
): Promise<void> {
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'),

View File

@ -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) });
}
/**