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