Let's say I have an Article model which has one field with the name of the article in different languages:
class Article {
constructor(public name: Translation[]) { }
}
class Translation {
constructor(
public language: string,
public text: string
) { }
}
I'd like to be able to call a method to translate that article name to the language given as an argument:
article.name.translate('EN')
How could I add that method to that array of translations?
Translation[], you may want to create a custom collection (perhapsTranslationCollection. Otherwise, create a getter, makingnameeither private or protected.