【发布时间】:2021-08-08 12:45:33
【问题描述】:
我试图用这个问题Angular ngx-translate usage in typescript 中的所有这些示例来解决我的任务我不知道如何将 TranslateService 连接到我的方法。
瑞典语翻译文件se.json(无钥匙)
{
NAME: Namn
}
英文翻译文件en.json(无键)
{
NAME: Name
}
打字稿:
从“@ngx-translate/core”导入{ TranslateService };
constructor {
private translate: TranslateService
} {
this.translate.use(localStorage.getItem("language")); // Get selected language
}
我要翻译的方法:
setColumns(): void {
this.loggedInUserType = Meteor.user().profile.user_type;
if (this.type === "history") {
this.columns = [
{ header: "NAME" },
{ header: "TOTALSUM" },
{ header: "VAT" },
{ header: "INVOICES" },
];
} else if (this.type === "clients") {
this.columns = [
{ header: "NAME" },
{ header: "ORGANIZATIONNUMBER" },
{ header: "CITY" },
{ header: "COUNTRY" },
{ header: "ACTIONS" },
];
this.getClients();
}
}
【问题讨论】: