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

[Bug] Cli push doesn't recognize key and tags in the translate pipe when there are variables defined using pipes #177

Closed
mgrilec opened this issue Feb 15, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@mgrilec
Copy link

mgrilec commented Feb 15, 2023

Current Behavior
The cli push doesn't recognize the key and tags.

Expected Behavior
Cli push should recognize key and tags.

Steps to Reproduce
Have somewhere in your HTML

"{{ '{var1}' | translate:{ _key: 'some-key', _tags: 'some tags', var1: someDate | date: 'dd.MM.yyyy' } }}"
txjs-cli push

Possible Solution
??

Possible Implementation
The translate params are read by passing the whole params object to Function(`"use strict";return (${obj})`)();, which doesn't parse well. The key, tags and all other predefined keys should be parsed using a regex with a capturing group. Other params are not useful for the parser anyway.

@mgrilec mgrilec added the bug Something isn't working label Feb 15, 2023
@mgrilec mgrilec changed the title [Bug] [Bug] Cli push doesn't recognize key and tags in the translate pipe when there are variables defined using pipes Feb 16, 2023
@pablotransifex
Copy link
Contributor

pablotransifex commented Feb 19, 2023

Hello @mgrilec and thank you for referring this parsing issue. The truth is that the Angular pipe lacks of good parsing, when no references to variables are in place, the tags are recognized and pushed, but when in the parameters are references to variables, we cannot understand using a simple parsing, and thus the parameters are ignored (all).

I try to minimize the side effects in this PR.

But in this case, the parser cannot extract any value for the _tags parameter, because we're not doing dynamic evaluation, just parsing:
<p class="using-pipe-with-tags-invalid">{{ "{var3}" | translate: { _key: "some-key-three", _tags: variableWithTags, var3: "valid value" } }}</p>

NOTE: For the translate pipe parameters, is better to use quotes for delimiting the string values, otherwise the results are unexpected.

Let's wait for the reviews and when deployed, give it a try.

pablotransifex added a commit that referenced this issue Feb 20, 2023
Fix for issue #177 and improve Angular parser tests
@mgrilec
Copy link
Author

mgrilec commented Mar 3, 2023

My example still doesn't work.

NOTE: For the translate pipe parameters, is better to use quotes for delimiting the string values, otherwise the results are unexpected.

It's not possible to use double quotes in cases where the pipe has to be used inside attributes.

<input placeholder="'Password' | translate : { _key: 'password' }">

What do you suggest to use there?

@pablotransifex
Copy link
Contributor

Hello @mgrilec I will look into it,, I think the regex for these specific syntax has some problem. I'll try to find a fix ASAP.

Thank you for the feedback!

@pablotransifex
Copy link
Contributor

@mgrilec I've prepared a [pull request](PR #184) to address this bug.

@pablotransifex
Copy link
Contributor

@mgrilec We've released the version 5.1.1. Please feel free to check if the issue is fixed for you.

@pablotransifex
Copy link
Contributor

@mgrilec Have you tested this one with the latest release?

@pablotransifex
Copy link
Contributor

Closing this one, as is the same as #183 .

If something come up, we can reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants