Trying to retrieve the language setting from localHost and implement it in a translation pipe as shown below:
transform(value: string): string {...
localStorage.setItem("language", JSON.stringify("en"));
let language = JSON.parse(localStorage.getItem("language") ?? "en");
language = language as keyof typeof translates[number];
const translates: {
key: string;
cz: string;
en: string;
}[]
let returnTranslate = "";
translates.forEach((item) => {
if (item["key"] === value) {
returnTranslate = item[language];
}
});
Encountering an error message stating:
'Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{ key: string; cz: string; en: string; }''
This problem occurs in the following part of the code:
item[language]