本文整理匯總了TypeScript中ng2-translate/ng2-translate.TranslateService.setDefaultLang方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TranslateService.setDefaultLang方法的具體用法?TypeScript TranslateService.setDefaultLang怎麽用?TypeScript TranslateService.setDefaultLang使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ng2-translate/ng2-translate.TranslateService
的用法示例。
在下文中一共展示了TranslateService.setDefaultLang方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: constructor
constructor(translate: TranslateService) {
let userLang = navigator.language.split('-')[0];
userLang = /(es|en)/gi.test(userLang) ? userLang : 'en';
translate.setDefaultLang('en');
translate.use(userLang);
}
示例2: constructor
constructor(private translate: TranslateService, private titleService: Title) {
// this language will be used as a fallback when a translation isn't found in the current language
translate.setDefaultLang('en');
// the lang to use, if the lang isn't available, it will use the current loader to get them
translate.use('en');
}
示例3: constructor
/** Sets the app language. */
constructor(
private translate: TranslateService,
private authService: AuthService
) {
translate.setDefaultLang('en');
translate.use('pt');
}
示例4: constructor
constructor(translate: TranslateService) {
var userLang = navigator.language.split('-')[0];
userLang = /(cs|en)/gi.test(userLang) ? userLang : 'cs';
// jazyk, který se použije pokud nebude jazyk automaticky detekován
translate.setDefaultLang('cs');
translate.use(userLang);
}
示例5: constructor
constructor(private navController: NavController,
private platform:Platform,public storageProvider:StorageProvider,
public fbProvider:FbProvider, public kakaoProvider:KakaoProvider,
public emailProvider:EmailProvider,private nativeStorage: NativeStorage,private app:App,
private translateService:TranslateService, private splashScreen: SplashScreen){
console.log("ErrorPage constructor");
//this.android_platform=this.platform.is('android');
//this.reason=this.storageProvider.errorReason;
if(!navigator.language.startsWith("ko")){
translateService.setDefaultLang('en');
translateService.use('en');
}else{
translateService.setDefaultLang('ko');
translateService.use('ko');
}
}
示例6: ngOnInit
public ngOnInit(): void {
// Set Language
this.translate.setDefaultLang('en');
this.translate.setTranslation('en', require('./../assets/i18n/en.json'));
// Print configuration to console
console.log('App config: ', AppConfig);
}
示例7: constructor
constructor(private _translate: TranslateService) {
var userLang = navigator.language.split('-')[0]; // use navigator lang if available
userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';
// this language will be used as a fallback when a translation isn't found in the current language
_translate.setDefaultLang('en');
// the lang to use, if the lang isn't available, it will use the current loader to get them
_translate.use(userLang);
}
示例8: constructor
constructor(
translate: TranslateService,
router: Router
) {
translate.setTranslation('en', require('../translations/locale-en.json'));
translate.setDefaultLang('en');
translate.use('en');
router.navigate(['/home']);
}
示例9: translateConfig
translateConfig() {
var userLang = navigator.language.split('-')[0]; // use navigator lang if available
userLang = /(fr|en)/gi.test(userLang) ? userLang : 'fr';
// this language will be used as a fallback when a translation isn't found in the current language
this.translate.setDefaultLang('fr');
// the lang to use, if the lang isn't available, it will use the current loader to get them
this.translate.use(userLang);
}
示例10: constructor
constructor(translate: TranslateService) {
console.log('Environment config', Config);
let userLang = navigator.language.split('-')[0];
userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';
translate.setDefaultLang('en');
translate.use(userLang);
}