I have tried to solve my task with all of these examples in this question Angular ngx-translate usage in typescript I do not know how to connect TranslateService to my method.
Swedish translation file se.json
(without key)
{
NAME: Namn
}
English translation file en.json
(without key)
{
NAME: Name
}
typescript:
import { TranslateService } from "@ngx-translate/core";
constructor {
private translate: TranslateService
} {
this.translate.use(localStorage.getItem("language")); // Get selected language
}
Method that I want to translate:
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();
}
}