exportdefaultclassStringResourceextendsBaseStringResource{publicusername="यूज़र नेम";publicuserNotFound(name:string):string{return`'${name}' यूज़र नहीं मिला`;}}
Benefit is, you can write methods which can accept input and different language can format differently. I know you could put c style or c# style placeholder formatting.
But in this case, StringResource class can access various other libraries to perform substitution. And if you make methods async, you can still access some other JSON and perform substitution.
In Web Atoms, we use Dependency Injection based on currently selected language,
{lang}is resolved at time of module loading./en-US/StringResource.ts/hi/StringResource.tsBenefit is, you can write methods which can accept input and different language can format differently. I know you could put c style or c# style placeholder formatting.
But in this case,
StringResourceclass can access various other libraries to perform substitution. And if you make methods async, you can still access some other JSON and perform substitution.Dependency Injection in Web Atoms
Akash Kava ・ Jun 25 ・ 3 min read