IDEMSInternational / open-app-builder

PLH App Frontend
GNU General Public License v3.0
5 stars 24 forks source link

[BUG] Carriage return \r messes up translations #2169

Closed esmeetewinkel closed 7 months ago

esmeetewinkel commented 8 months ago

Describe the bug Some users seem to introduce \r when they work on content (as a type of line break). This comes through in our content sync as:

        "section_text_1": {
          "eng": "Select the profile icon from the bottom navigation bar. \n\nChoose “About you” \n\nType your name under “Your name” \n\nSelect your state from the dropdown menu \n\rTap Save"
        },

When uploading this string to Crowdin for translation, Crowdin interprets the \n but not the \r:

image

Syncing the translation back into the app from Crowdin, we get:

  {
    "SourceText": "Select the profile icon from the bottom navigation bar. \n\nChoose “About you” \n\nType your name under “Your name” \n\nSelect your state from the dropdown menu \n\\rTap Save",
    "text": "Pilih ikon profil dari bar navigasi di bawah. \n\nPilih “Tentang Anda” \n\nMasukkan nama anda di bahagian “Nama Anda” \n\nPilih negeri anda daripada menu juntai bawah \n\\rKlik Simpan",
    "type": "data_list",
    "note": ""
  },

which no longer matches the original string: every \r has now become \\r. Hence, in the app the translation is missing:

image

(use case from FaciNK https://github.com/IDEMSInternational/plh-facilitator-app-my-content/pull/64/)

Desired behaviour To me it would make sense if, from the start (parser), every \r is replaced by \n - this would fix all issues that occur later.

esmeetewinkel commented 8 months ago

Currently speaking to Crowdin support, since the issue of replacing \r (in .pot) by \\r (in .po) lies with Crowdin

esmeetewinkel commented 7 months ago

Resolved this with Crowdin by adding post-processing to replace \\r by \r in the .po file