WeblateOrg / weblate

Web based localization tool with tight version control integration.
https://weblate.org/
GNU General Public License v3.0
4.49k stars 993 forks source link

Newline handling from XLIFF #10811

Closed wirthandras closed 7 months ago

wirthandras commented 8 months ago

Describe the issue

The weblate user is created some translations with newline characters (the newline control character was selected in weblate interface)

image

image

This text was serialized into git repository without problems, the newline characters are exist in XLIFF 1.2 files.

But the next weblate syncronization (I mean import a new group of text via rest api by setting the source branch) removed the existing newlines from text:

image

I already tried

Steps to reproduce the behavior

Single line text added to weblate as source text from XLIFF 1.2 source file from GIT feature branch The translator give a more detailed text with some newline characters Localizations are synchronized into git origin with push branch (and merged with master branch) A new source branch is created from master (including some new texts which are not really relevant here) and set that branch into weblate as source branch via REST API.

Expected behavior

Keep newlines which inserted by weblate tools

Screenshots

The automatic feedback in insights related to component: image

Exception traceback

No response

How do you run Weblate?

Docker container

Weblate versions

5.2.1

Weblate deploy checks

No response

Additional context

No django settings modified

nijel commented 8 months ago

Can you please share a snippet of your XLIFF file before and after Weblate edit? My guess is that the element didn't have xml:space="preserve" and translate-toolkit (library we use for manipulating the files) did not add it when changing the string.

github-actions[bot] commented 8 months ago

The issue you've reported needs to be addressed in the translate-toolkit. Please file the issue there, and include links to any relevant specifications about the formats (if applicable).

wirthandras commented 8 months ago

Yeah, i can confirm there is no xml:space="preserve"

<trans-unit id="8864d0bd25f99594bbfb59780cb19a091946d8e6" datatype="html">
        <source>Status: You have started the form but it is not completed. Please select the continue button below to resume the form process. Please have the following documents available: • INE (Credencial para votar) o pasaporte, vigentes • Carátula del estado de cuenta bancario personal • Cuenta CLABE Bancaria • Constancia de Situación Fiscal con el Régimen de Sueldos y Salarios e Ingresos Asimilados a Salarios, con una vigencia no mayor a 90 días, completa, en FORMATO PDF</source>
        <target state="translated">Estado actual:
Empezaste el proceso en pero no lo has completado.
Por favor, selecciona el botón “continuar” de abajo para continuar el proceso en.

Por favor, ten a la mano los siguientes documentos para completar el proceso:
• INE (Credencial para votar) o pasaporte, vigentes
• Carátula del estado de cuenta bancario personal
• Cuenta CLABE Bancaria
• Constancia de Situación Fiscal con el Régimen de Sueldos y Salarios e Ingresos Asimilados a Salarios, con una vigencia no mayor a 90 días, completa, en FORMATO PDF</target>
        <context-group purpose="location">
          <context context-type="sourcefile">src/app/settings/component/profile/example/example.component.html</context>
          <context context-type="linenumber">3</context>
        </context-group>
        <note priority="1" from="description">settings</note>
      </trans-unit>
nijel commented 7 months ago

The xml:space="preserve" is properly added upon editing the file, I've just added tests for this in https://github.com/translate/translate/pull/5168.

Is there something else changing the XLIFF files? Maybe it is removing it?

github-actions[bot] commented 7 months ago

This issue has been marked as a question by a Weblate team member. Why? Because it belongs more to the professional Weblate Care or community Discussions than here. We strive to answer these reasonably fast here, too, but purchasing the support subscription is more responsible and faster for your business. And it makes Weblate stronger as well. Thanks!

In case your question is already answered, making a donation is the right way to say thank you!

wirthandras commented 7 months ago

@nijel Hi I have made a test run related to this topic, I have added a xml:space="preserve" as you mentioned before into the input xliff file:

<trans-unit id="3330244922547581181" datatype="html">
        <source  xml:space="preserve">Hello World3 test ride</source>
        <context-group purpose="location">
          <context context-type="sourcefile">src/app/app.component.html</context>
          <context context-type="linenumber">13</context>
        </context-group>
      </trans-unit>

after text change in weblate (commit, push) this is the result:

<trans-unit id="3330244922547581181" datatype="html">
        <source xml:space="preserve">Hello World3 test ride

bla bla

bla blaline2</source>
        <target state="translated">Hello World3 test ride

bla bla SP

bla blaline2 SP</target>
        <context-group purpose="location">
          <context context-type="sourcefile">src/app/app.component.html</context>
          <context context-type="linenumber">13</context>
        </context-group>
      </trans-unit>

it seems to me the target tag has not marked with the similar xml:space="preserve" attribute

This could be an open question, but unfortunatly that does not solve my problem, since we are using Angular and [I18n ] extractor (https://angular.io/cli/extract-i18n) to generate input files for weblate, and it seems to this extractor does not provide this attribute. (i see some reference, but does not work as expected for this situation)

Thanks for help, I need to thinking about other solution

github-actions[bot] commented 7 months ago

The issue you've reported needs to be addressed in the translate-toolkit. Please file the issue there, and include links to any relevant specifications about the formats (if applicable).

github-actions[bot] commented 7 months ago

Thank you for your report; the issue you have reported has just been fixed.