Skip to content

describe translations drops the CR of a CRLF source, so create translations cannot match it #1890

Open

Description

@tgolembiewski

Summary

describe translations prints a source string that contains CRLF line breaks with LF only. Running the same file
back through create or modify translations then reports the entry as unknown, and the text stays empty:

No text has "{1} days\n" as its source, and nothing carries this de_CH translation,
so there is no telling where it went. The text may have been deleted, or the key may be a typo.

The same entry written with the CR kept inside the quoted string ('{1} days\r\n', a raw CR byte in the file) is
matched and written. So matching itself is exact and works; the round trip from describe to create loses the CR.

Why it matters

Texts with CRLF come with Marketplace modules. In a scratch app with WorkflowCommons 4.10.0 there are 12 texts with
a CRLF source and no de_CH text, 9 unique strings (by text: 6 in WorkflowCommons, 1 in FeedbackModule 4.0.2, 5 in
Atlas_Web_Content templates). Three of them are confirmation questions, for example "Are you sure you would like to withdraw this
workflow?\r\n\r\nThis means ...".

In an app whose default language is not English, those confirmation questions are CE4899 errors ("Empty question.
[German, Switzerland]") until they have a default-language text. The documented describe -> fill -> create workflow
(the translations skill) leaves exactly those errors behind.

Reproduce (mxcli v0.32.0, Mendix 11.12.1)

  1. Use an app with WorkflowCommons 4.10.0, default language de_CH, languages en_US and de_CH. The module's texts are
    en_US only.
  2. alter settings LANGUAGE (DefaultLanguageCode: 'en_US'); (describe and create are keyed on the default language:
    A Marketplace module that ships no texts in the app's default language: 99 CE4899, and describe/create translations cannot fill them #1887).
  3. describe translations in WorkflowCommons for de_CH. The entry for the dynamic text "{1} days\r\n" is printed
    as follows (od -c of the output):
    '   {   1   }       d   a   y   s  \n   '       a   s       '   '   ,
    
    There is no \r. The model has {1} days\r\n (Texts$Translation.Text in the unit's BSON).
  4. Fill in a translation and run the file with create or modify translations in WorkflowCommons for de_CH (...).
    • The message above is printed for every CRLF source in the file.
    • mx check still lists the 3 CE4899 on the confirmation questions.
  5. Write the same entry with the CR kept, as '{1} days<CR><LF>' as '{1} Tage<CR><LF>' with raw bytes in the file.
    • It lands: both texts with that source get {1} Tage\r\n.
    • In a full run with the CR kept for all of them, mx check goes from 99 CE4899 to 0.

Expected

The output of describe translations can be run again as it is. Any of these would do:

  • keep the CR in the quoted string, as create accepts it;
  • write an escape that create reads back (\r\n);
  • have create treat CRLF and LF as the same when it matches a source.

The third also helps files written by hand or by an agent, which write LF.

Related

Measured on v0.32.0 only; the only commit on main since v0.32.0 that touches translations (#2327, show message translations on an in-place edit) does not change describe or create translations.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions