本文整理汇总了TypeScript中ionic-native.Globalization.getPreferredLanguage方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Globalization.getPreferredLanguage方法的具体用法?TypeScript Globalization.getPreferredLanguage怎么用?TypeScript Globalization.getPreferredLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ionic-native.Globalization
的用法示例。
在下文中一共展示了Globalization.getPreferredLanguage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: if
this.storage.get('user').then((user) =>{
if(user != "" && user != undefined){
this.user = JSON.parse(user.toString());
}
this.storage.get('firstRun').then((resp) => {
if(this.user)
this.rootPage = TabsPage;
else if(resp != "" && user != undefined)
this.rootPage = LoginPage;
else
this.rootPage = SlidePage;
});
Splashscreen.hide();
Globalization.getPreferredLanguage().then((obj) =>{//get device language
console.log(obj.value);
this.initializeTranslateServiceConfig(obj.value.split('-')[0]);//initialize sending lowercase language
this.storage.set('language', obj.value.split('-')[0]);
}, (err)=>{
console.log(err);
this.initializeTranslateServiceConfig(defaultLanguage);//initialize sending lowercase language default
this.storage.set('language', defaultLanguage);
});
//this.initializeTranslateServiceConfig();
},
示例2: initializeIosApp
initializeIosApp(){
this.confData.load();
this.rootPage = SlidePage;
this.initializePush();
Globalization.getPreferredLanguage().then((obj) =>{//get device language
console.log(obj.value);
this.initializeTranslateServiceConfig(obj.value.split('-')[0]);//initialize sending lowercase language
}, (err)=>{
console.log(err);
this.initializeTranslateServiceConfig(defaultLanguage);//initialize sending lowercase language default
});
Splashscreen.hide();
}
示例3: initialize
/**
* @private
* @static
* Initializes the language retriever structure
* @return {void}
*/
private static initialize(): void {
Strings.language = Globalization.getPreferredLanguage()
.then( response => Strings.setLanguage(response.value))
.catch( error => Strings.setLanguage(''))
.then( language => TextMap[language]);
}