本文整理汇总了TypeScript中@ngx-translate/core.TranslateService.setTranslation方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TranslateService.setTranslation方法的具体用法?TypeScript TranslateService.setTranslation怎么用?TypeScript TranslateService.setTranslation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ngx-translate/core.TranslateService
的用法示例。
在下文中一共展示了TranslateService.setTranslation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(translate: TranslateService) {
let userLang = navigator.language.split('-')[0]; // use navigator lang if available
translate.setDefaultLang('en');
translate.setTranslation('fr', {
JS: 'Javascript',
DEV: 'Développement',
DATA: 'Données',
INTE: 'Integration',
HOME:'Accueil',
PROJECTS:'Projets',
TECHS:'Technologies',
TOOLS:'Outils'
});
translate.setTranslation('en', {
JS: 'Javascript',
DEV: 'Development',
DATA: 'Data',
INTE: 'Integration',
HOME:'Home',
PROJECTS:'Projects',
TECHS:'Technologies',
TOOLS:'Tools'
});
// the lang to use, if the lang isn't available, it will use the current loader to get them
translate.use(userLang);
}
示例2: constructor
constructor(viewContainerRef: ViewContainerRef,
private renderer: Renderer,
private router: Router,
private translate : TranslateService) {
this.viewContainerRef = viewContainerRef;
translate.addLangs(["ru", "cz", "en"]);
translate.setTranslation("ru", RU);
translate.setTranslation("en", EN);
translate.setTranslation("cz", CZ);
translate.setDefaultLang('ru');
let browserLang = translate.getBrowserLang();
translate.use(browserLang.match(/ru/) ? browserLang : 'ru');
}
示例3:
).subscribe(([langData, appData]) => {
// setting language data
this.translate.setTranslation(this.i18n.defaultLang, langData);
this.translate.setDefaultLang(this.i18n.defaultLang);
// application data
const res: any = appData;
// 应用信息:包括站点名、描述、年份
this.settingService.setApp(res.app);
// 用户信息:包括姓名、头像、邮箱地址
this.settingService.setUser(res.user);
// ACL:设置权限为全量
this.aclService.setFull(true);
// 初始化菜单
this.menuService.add(res.menu);
// 设置页面标题的后缀
this.titleService.suffix = res.app.name;
},
示例4: constructor
constructor(private translate: TranslateService) {
translate.use('zh-cn');
translate.setTranslation('zh-cn', {
common: {
OK: '确定',
CANCEL: '取消',
DELETING: '删除中...',
DELETE_CONFIRM: '确认删除',
tips: {
'NO_RESULT': '没有数据',
'NO_RESULT_TARGET': '没有{{target}}'
},
confirm: {
CONTENT_DEFAULT: '确认删除这个吗?',
CONTENT: '确认删除项目 <code>{{name}}</code> 吗?'
},
},
mission: {
PROJECT: '项目',
'TASK': '任务'
}
});
}
示例5: constructor
constructor(private translateService: TranslateService) {
// Embed languages to avoid extra HTTP requests
translateService.setTranslation('en-US', enUS);
translateService.setTranslation('uk-UA', ukUA);
}
示例6: constructor
public constructor(translate: TranslateService) {
translate.setTranslation('es', ES, true);
}
示例7: beforeEach
beforeEach(inject([TranslateService], (translateService: TranslateService) => {
translateService.setTranslation('es', ES, true);
translateService.setDefaultLang('es');
translateService.use('es');
}));
示例8: addTranslations
addTranslations(translations: AnyKeyValue) {
return observableOf(this.translate.setTranslation(this.translate.currentLang, translations, true));
}
示例9:
locales.forEach((locale) => {
// use setTranslation() with the third argument set to true
// to append translations instead of replacing them
this._translateService.setTranslation(locale.lang, locale.data, true);
});