Git Product home page Git Product logo

Comments (9)

aurambaj avatar aurambaj commented on May 27, 2024

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.

danjor avatar danjor commented on May 27, 2024

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.
image
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.

ehoogerbeets avatar ehoogerbeets commented on May 27, 2024

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 &lt;x id="message" equiv-text="message"/&gt;? This action is irreversible.</source>
			<target xml:lang="fr-FR">Do you really want to delete &lt;x id="message" equiv-text="message"/&gt;? This action is irreversible.</target>
		</trans-unit>
	<body>
  </file>
</xliff>

from mojito.

danjor avatar danjor commented on May 27, 2024

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.

danjor avatar danjor commented on May 27, 2024

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.

ehoogerbeets avatar ehoogerbeets commented on May 27, 2024

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.

aurambaj avatar aurambaj commented on May 27, 2024

@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.

ehoogerbeets avatar ehoogerbeets commented on May 27, 2024

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.

danjor avatar danjor commented on May 27, 2024

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.

image

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 &lt;x id="linkedMethodName" equiv-text="this.linkedMethods.value[index].name"/&gt;</source>
        <note priority="1" from="description">Action verb</note>
</trans-unit>

exported translation file (pull)

<trans-unit id="1014715239941102606" datatype="html">
        <source>Remove &lt;x id="linkedMethodName" equiv-text="this.linkedMethods.value[index].name"/></source>
        <target xml:lang="fr-FR">Suppr &lt;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.
/(\&lt;x(\s+([^\/]*))\/>)/gi instead of /(\&lt;x(\s+([^\/]*))\/\&gt;)/gi

from mojito.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.