MOBILE-3615 menu: Use parent language if any on docs url

main
Pau Ferrer Ocaña 2021-05-13 17:03:57 +02:00
parent ecab609487
commit d17da64a31
3 changed files with 19 additions and 4 deletions

View File

@ -51,7 +51,8 @@
[disabled]="showFilters.future == 'disabled'">
{{ 'addon.block_myoverview.future' | translate }}
</ion-select-option>
<ion-select-option class="ion-text-wrap" value="past" *ngIf="showFilters.past != 'hidden'" [disabled]="showFilters.past == 'disabled'">
<ion-select-option class="ion-text-wrap" value="past" *ngIf="showFilters.past != 'hidden'"
[disabled]="showFilters.past == 'disabled'">
{{ 'addon.block_myoverview.past' | translate }}
</ion-select-option>
<ng-container *ngIf="showFilters.custom != 'hidden'">

View File

@ -118,6 +118,19 @@ export class CoreLangProvider {
return value.charAt(0).toUpperCase() + value.slice(1);
}
/**
* Get the parent language defined on the language strings.
*
* @param currentLanguage Current language.
* @returns If a parent language is set, return the index name.
*/
getParentLanguage(currentLanguage: string): string | undefined {
const parentLang = Translate.instant('core.parentlanguage');
if (parentLang != '' && parentLang != 'core.parentlanguage' && parentLang != currentLanguage) {
return parentLang;
}
}
/**
* Change current language.
*
@ -131,9 +144,9 @@ export class CoreLangProvider {
promises.push(new Promise((resolve, reject) => {
CoreSubscriptions.once(Translate.use(language), data => {
// It's a language override, load the original one first.
const fallbackLang = Translate.instant('core.parentlanguage');
const fallbackLang = this.getParentLanguage(language);
if (fallbackLang != '' && fallbackLang != 'core.parentlanguage' && fallbackLang != language) {
if (fallbackLang) {
CoreSubscriptions.once(
Translate.use(fallbackLang),
fallbackData => {

View File

@ -242,7 +242,8 @@ export class CoreUrlUtilsProvider {
}
try {
const lang = await CoreLang.getCurrentLanguage();
let lang = await CoreLang.getCurrentLanguage();
lang = CoreLang.getParentLanguage(lang) || lang;
return docsUrl.replace('/en/', '/' + lang + '/');
} catch (error) {