MOBILE-2510 lang: Always use English as fallback language
parent
4de2510140
commit
036799eb40
|
@ -25,7 +25,8 @@ import { CoreConfigConstants } from '../configconstants';
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CoreLangProvider {
|
export class CoreLangProvider {
|
||||||
protected fallbackLanguage = CoreConfigConstants.default_lang || 'en';
|
protected fallbackLanguage = 'en'; // Always use English as fallback language since it contains all strings.
|
||||||
|
protected defaultLanguage = CoreConfigConstants.default_lang || 'en'; // Lang to use if device lang not valid or is forced.
|
||||||
protected currentLanguage: string; // Save current language in a variable to speed up the get function.
|
protected currentLanguage: string; // Save current language in a variable to speed up the get function.
|
||||||
protected customStrings = {}; // Strings defined using the admin tool.
|
protected customStrings = {}; // Strings defined using the admin tool.
|
||||||
protected customStringsRaw: string;
|
protected customStringsRaw: string;
|
||||||
|
@ -35,7 +36,7 @@ export class CoreLangProvider {
|
||||||
private globalization: Globalization) {
|
private globalization: Globalization) {
|
||||||
// Set fallback language and language to use until the app determines the right language to use.
|
// Set fallback language and language to use until the app determines the right language to use.
|
||||||
translate.setDefaultLang(this.fallbackLanguage);
|
translate.setDefaultLang(this.fallbackLanguage);
|
||||||
translate.use(this.fallbackLanguage);
|
translate.use(this.defaultLanguage);
|
||||||
|
|
||||||
platform.ready().then(() => {
|
platform.ready().then(() => {
|
||||||
this.getCurrentLanguage().then((language) => {
|
this.getCurrentLanguage().then((language) => {
|
||||||
|
@ -191,18 +192,18 @@ export class CoreLangProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof CoreConfigConstants.languages[language] == 'undefined') {
|
if (typeof CoreConfigConstants.languages[language] == 'undefined') {
|
||||||
// Language not supported, use fallback language.
|
// Language not supported, use default language.
|
||||||
return this.fallbackLanguage;
|
return this.defaultLanguage;
|
||||||
}
|
}
|
||||||
|
|
||||||
return language;
|
return language;
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
// Error getting locale. Use default language.
|
// Error getting locale. Use default language.
|
||||||
return this.fallbackLanguage;
|
return this.defaultLanguage;
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Error getting locale. Use default language.
|
// Error getting locale. Use default language.
|
||||||
return Promise.resolve(this.fallbackLanguage);
|
return Promise.resolve(this.defaultLanguage);
|
||||||
}
|
}
|
||||||
}).then((language) => {
|
}).then((language) => {
|
||||||
this.currentLanguage = language; // Save it for later.
|
this.currentLanguage = language; // Save it for later.
|
||||||
|
|
Loading…
Reference in New Issue