-
Notifications
You must be signed in to change notification settings - Fork 73
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
Interpolation get removed after translation done #810
Comments
could you screenshot the string in the webapp/worbench. Does it show the |
The x tag is not part of the xliff xml schema, so the parser will drop it. If you want an xml element to be a part of the string in an xliff string, the "<" characters need to be escaped: <?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en-US" datatype="plaintext" original="ng2.template">
<body>
<trans-unit id="delete-service-warning" datatype="html">
<source>Do you really want to delete <x id="message" equiv-text="message"/>? This action is irreversible.</source>
<target xml:lang="fr-FR">Do you really want to delete <x id="message" equiv-text="message"/>? This action is irreversible.</target>
</trans-unit>
<body>
</file>
</xliff> |
Thanks for you reply. Sadly Angular does not escape its own xml tag for interpolation in source tag when extracting messages from ts and html. I'm afraid mojito can't be used out of the box for Angular xlf files that for sure will have a trans-unit with interpolation. Shouldn't this be handled by mojito, by updating the parser or something? |
I found a script for escape and replace angular <x interpolation tags. https://gist.github.com/jacob-jonkman/cc48d1f3690bc1accf9f36881e09ef47 https://gist.github.com/jacob-jonkman/2d5d26df672376bc31cd08710708a96b |
Yes, those look like a good solution and that it would work. I think it might be difficult to update the parser in mojito because it is a 3rd party parser and it uses the xml schema to enforce the structure of the xliff, so this escaping/unescaping is a good workaround. |
@ehoogerbeets what's your source for saying |
Oh wow! I did not know about that! I guess it is part of the xliff schema. I guess the parser has a bug then. |
I used the previous script to escape <x tags and then push, also import and pull. resources.xliff without escaping interpolation tags <trans-unit id="1014715239941102606" datatype="html">
<source>Remove <x id="linkedMethodName" equiv-text="this.linkedMethods.value[index].name"/></source>
<note priority="1" from="description">Action verb</note>
</trans-unit> escaped resources.xliff (push) <trans-unit id="1014715239941102606" datatype="html">
<source>Remove <x id="linkedMethodName" equiv-text="this.linkedMethods.value[index].name"/></source>
<note priority="1" from="description">Action verb</note>
</trans-unit> exported translation file (pull) <trans-unit id="1014715239941102606" datatype="html">
<source>Remove <x id="linkedMethodName" equiv-text="this.linkedMethods.value[index].name"/></source>
<target xml:lang="fr-FR">Suppr <x id="linkedMethodName" equiv-text="this.linkedMethods.value[index].name"/></target>
<note from="description" priority="1">Action verb</note>
</trans-unit> edit : in fact exported file (pull) has kept the opening <x tag escaped but unescaped the closing tag ! |
I'm using xliff 1.2 files.
After translating fields from the webapp, interpolation tags get removed from the target.
become
Then, it can't be used like this for Angular app.
The text was updated successfully, but these errors were encountered: