Comments (9)
could you screenshot the string in the webapp/worbench. Does it show the Remove <x id="linkedMethodName" equiv-text="name"/>
as plain text in the source? Have you kept it in the target as well?
from mojito.
Interpolation in not shown in the webapp
:/xlf/MyRepo# mojito repo-create -n MyRepo -l fr-FR
Create repository: MyRepo
Extracting locale: fr-FR
Extracted RepositoryLocale:
-- bcp47Tag = fr-FR
-- isFullyTranslated = true
created --> repository id: 2
:/xlf/MyRepo# mojito push -r MyRepo -s /xlf/MyRepo/ -sr "^resources.xliff$"
Push assets to repository: MyRepo
- Uploading: resources.xliff
--> asset id: 2, task: 13
Running, task id: 13
Creating asset: resources.xliff (14) Done
Process asset content, id: 2 (15) Done
Extracting text units from asset (16) Done
Create new text units (17) Done
Updating branch asset text units (19) Done
Updating merged asset text units (21) Done
Perform leveraging (22) Done
Finished
Interpolation is not displayed in the webapp.
I'm not editing the translation and simply export using pull.
:/xlf/MyRepo# mojito pull -r MyRepo -s /xlf/MyRepo -t /xlf/MyRepoOut
Pull localized asset from repository: MyRepo
Localizing: resources.xliff
- Processing locale: fr-FR --> resources_fr-FR.xliff
resources.xliff from push was :
<?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>
</trans-unit>
<body>
</file>
</xliff>
without editing nothing in the webapp, resulting resources_fr-FR.xliff from pull was :
<?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 ? This action is irreversible.</target>
</trans-unit>
<body>
</file>
</xliff>
Target interpolation has been removed, but should be kept.
from mojito.
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>
from mojito.
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?
from mojito.
I found a script for escape and replace angular <x interpolation tags.
I will also try with this.
https://gist.github.com/jacob-jonkman/cc48d1f3690bc1accf9f36881e09ef47
https://gist.github.com/jacob-jonkman/2d5d26df672376bc31cd08710708a96b
from mojito.
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.
from mojito.
@ehoogerbeets what's your source for saying <x>
is not Xliff schema. I was under the impression it is, at least as specified here: http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html
from mojito.
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.
from mojito.
I used the previous script to escape <x tags and then push, also import and pull.
<x tags are correctly displayed in the webapp and kept in the exported translation file.
So it seems to work as expected by escaping interpolation tags.
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 could update the unescape script to handle this, even if it's strange.
/(\<x(\s+([^\/]*))\/>)/gi instead
of /(\<x(\s+([^\/]*))\/\>)/gi
from mojito.
Related Issues (20)
- Drops for Hungarian (hu-HU) are produced in charset ISO-8859-2
- IDs getting deleted after export
- Can't import TM file with .tmx extension
- Properties files push makes wrong IDs HOT 2
- [Question]: How the branches's merge works? it's not clear HOT 5
- Error while importing in new repo HOT 4
- XLF file not processed HOT 3
- Xliff trans-unit target state new remains even after review being done HOT 1
- XLIFF version 2 HOT 1
- using active user in Workbench/TextUnit.js HOT 1
- currentUser in workbnech component HOT 2
- Fails to install on macOS Monterey 12.5 HOT 1
- ReferenceError: Dispatcher token not provided HOT 2
- Multiline comments (.po) HOT 1
- -ERR:PROP-NOT-FOUND->
- Mojito Cli not working on M1 HOT 1
- Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException HOT 3
- Creating Repository in Webapp HOT 1
- Could you release new version? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mojito.