Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic string in translate instant #254

Open
Skaaala opened this issue Jan 25, 2022 · 0 comments
Open

Dynamic string in translate instant #254

Skaaala opened this issue Jan 25, 2022 · 0 comments

Comments

@Skaaala
Copy link

Skaaala commented Jan 25, 2022

Hello there,

I'm currently using ngx-translate-extract and found a problem with dynamic translations.

Let's say we have 2 variables

const a = 'First';
const b = 'Second';

and you want to use final translate string like
const c = '${translate.instant(a)} ${translate.instant(b)}';

Everything works correctly and you can see that in variable c there is translated string 'First Second'. But when you will try to run ngx-translate-extract it will shows error:

We cannot extract variable values passed to TranslateService

because into translate.instant you put variable instead of string.

Is there any fix or workaround? I found only that when you use translate['instant'] it will works correctly and not extract it, but it is not elegant solution at all :)

Maybe there will be good feature to create some expected comment like
// ngx-translate-extract prevent-next-line
to prevent next line from beeing extracted.

Kind regards
Jan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant