For example, we have a file with localized strings
{
"title": "Example title",
"description": "Some text"
}
Let's assume we also have a component with some custom decorator @I18n()
@Component({ ... })
@I18n('./my-translations.json')
export class MyAngularComponent {
}
And template
<h2>{{ i18n.title }}</h2>
<p>{{ i18n.description }}</p>
Is it possible to include one more external resource (besides templateUrl
and styleUrls
) into the component?
You could extend Component
decorator however i would not do that, since it may have undesired effects on compiler and depends on Component
changes between angular versions. I would rather allow multiple arguments/variable arguments/array parameter in I18n
decoroator or allow multiple I18n
decorators, it means that I18n
decorator should check for class modifications done by previous decorators and append its data accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With