本文整理汇总了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);
}