#Translate @Input data with @angular/localize
18 messages · Page 1 of 1 (latest)
then the translate service will pick up the right language itself to turn the key in text
I read docs but anyway don’t understand how to use it correct in template. It’s okay for some div. But how pass it in input?
I already have translation files and id
You can inject the translate service if you wanna translate it in the typescript. As you said in template you can pipe the key with the translate pipe.
as for your input, you either pass the key and translate later on, or you translate it before passing it. I will let you chose what seems best for you x)
Hold on, I have some big doubt going on, looking up things
I'm sorry I forgot I was using http://www.ngx-translate.com/ this whole time
🤦♂️
No wonder things did not add up between the link I send you and what I said along
Why don't you pass the translated text directly? And translate it in the parent template?
Yes that's what I suggested on the next line
So to add the native solution, you need to use $localize in your typescript, then when you compile in the differents locals, it will do it. Then you just pass the variable in your input
<app-create-stream-link
[title]="title"
[description]="description"
></app-create-stream-link>
protected title = $localize `offers:constructor`;
protected description = $localize `offers:constructor-desc`;
Something like that !
AFAIK, you can also directly use
<app-create-stream-link
title="some text" i18n-title="@@offers:constructor-desc"
description=" some description" i18n-description="@@offers:constructor-desc"
></app-create-stream-link>
(at least that works for standard HTML attributes)
nice !
Yeah, it works only for standard HTML attributes
Thank you very much guys