formio / formio.js

JavaScript powered Forms with JSON Form Builder
https://formio.github.io/formio.js
MIT License
1.88k stars 1.06k forks source link

[Issue with Translation if key contains '\r\n' Is there any another solution for this] #4428

Open Dev-Trilok opened 2 years ago

Dev-Trilok commented 2 years ago

I have taken all keys such as labels, placeholder, tooltip, and all other fields from formio JSON template and translated them using google translate API, All these working well on language change. But the issue at the HTML element component 'Content' input Field. If I press enter key in the input field then it creates ' \r\n' in formio Json template , also google translate it as same format but the translation does not work on render.

Attached image for more clarification : HTML element Content field:

image

Formio template JSON formed:

"label": "HTML", "tag": "p", "className": "", "attrs": [ { "attr": "", "value": "" } ], "content": "1.This is testing or
\r\n<span style=\"display:block;padding-left:50px\">\r\nAre you okay?
", "refreshOnChange": false, "customClass": "", "hidden": false, "modalEdit": false, "key": "html", "tags": [], "properties": {}, "conditional": { "show": null, "when": null, "eq": "", "json": "" }

translation code

i18n: { zh-TW: { "1.This is testing or
\r\n<span style=\"display:block;padding-left:50px\">\r\nAre you okay?
": "1.這是測試
<span style=\"display:block;padding-left:50px\">你還好嗎?
", "Submit": "提交" }

}

output

Only the submit button is translated: image

If the content is in one line then it's work. image Formio template JSON formed:

    "label": "HTML",
    "tag": "p",
    "className": "",
    "attrs": [
        {
            "attr": "",
            "value": ""
        }
    ],
    "content": "1.This is testing  <b>or</b><br><span style=\"display:block;padding-left:50px\">Are you okay?<br></span>",
    "refreshOnChange": false,
    "customClass": "",
    "hidden": false,
    "modalEdit": false,
    "key": "html",
    "tags": [],
    "properties": {},
    "conditional": {
        "show": null,
        "when": null,
        "eq": "",
        "json": ""
    },

translation code

i18n:{ zh-TW: { "1.This is testing or
<span style=\"display:block;padding-left:50px\">Are you okay?
": "1.這是測試
<span style=\"display:block;padding-left:50px\">你還好嗎?
", "Submit": "提交"

}

output:

image

Please let me know what can I do for translation work with '\r\n'

viralP1 commented 1 year ago

@Dev-Trilok Did you find any workaround?

Dev-Trilok commented 1 year ago

@viralP1 I didn't get enough time to further investigate into that at that time.

Sidiro23 commented 3 months ago

Thank you for reporting this issue. I am able to reproduce and have logged a ticket for the backlog. We are always willing to review any contributions to resolve this issue from the open source community.

For internal reference: FIO-8648

lane-formio commented 3 months ago

After review, we don't expect to resource a developer to investigate this in the near future but would be happy to review any contributions to resolve this behavior.