Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String with \r\n will not get translated properly. #76

Closed
Skrypt opened this issue Dec 13, 2023 · 5 comments · Fixed by #77
Closed

String with \r\n will not get translated properly. #76

Skrypt opened this issue Dec 13, 2023 · 5 comments · Fixed by #77

Comments

@Skrypt
Copy link
Contributor

Skrypt commented Dec 13, 2023

Example:

S["Webhook {0} failed to be added with an exception. \r\n{1}"

Result:

#: Aptix.Autodesk\ConstructionCloud\ConstructionCloudCommon\Commands\ProcessWebHooksCommand.cs:150
#. errors.Add(S["Webhook {0} failed to be added with an exception. \r\n{1}", addition.Id, ex.Message]);
msgctxt "Aptix.Autodesk.ConstructionCloud.ConstructionCloudCommon.Commands.ProcessWebHooksCommandHandler"
msgid "Webhook {0} failed to be added with an exception. 
{1}"
msgstr ""

Result expected:

#: Aptix.Autodesk\ConstructionCloud\ConstructionCloudCommon\Commands\ProcessWebHooksCommand.cs:150
#. errors.Add(S["Webhook {0} failed to be added with an exception. \r\n{1}", addition.Id, ex.Message]);
msgctxt "Aptix.Autodesk.ConstructionCloud.ConstructionCloudCommon.Commands.ProcessWebHooksCommandHandler"
msgid "Webhook {0} failed to be added with an exception. \r\n{1}"
msgstr ""
@Skrypt
Copy link
Contributor Author

Skrypt commented Dec 13, 2023

This causes a lot of issues later on when we try to automatically translate these string with Google translate as now the string is on 2 different lines. So now it tries to translate 2 different strings.

@hishamco
Copy link
Member

Please refer me to one of them in OC? I might need to check PO Extractor

@Skrypt
Copy link
Contributor Author

Skrypt commented Dec 13, 2023

Doing a quick search in OC did not return any result. Is it even possible to use \r\n in a translatable string? I'm not sure. My first guess was to try and debug this with a unit test simply.

@Skrypt
Copy link
Contributor Author

Skrypt commented Dec 13, 2023

Here it is:

image

@Skrypt Skrypt mentioned this issue Dec 13, 2023
@Skrypt
Copy link
Contributor Author

Skrypt commented Dec 14, 2023

Actually after doing more tests. \r should not be supported by the PoExtrator. It should throw an exception when finding it and warn the user because most tools that I used to parse Po files only supports the usage of \n

https://www.npmjs.com/package/gettext-parser
https://github.com/adams85/po

So based on that it should be:

Example:

S["Webhook {0} failed to be added with an exception. \n{1}"

Result expected:

#: Aptix.Autodesk\ConstructionCloud\ConstructionCloudCommon\Commands\ProcessWebHooksCommand.cs:150
#. errors.Add(S["Webhook {0} failed to be added with an exception. \n{1}", addition.Id, ex.Message]);
msgctxt "Aptix.Autodesk.ConstructionCloud.ConstructionCloudCommon.Commands.ProcessWebHooksCommandHandler"
msgid ""
msgid "Webhook {0} failed to be added with an exception. \n"
msgid "{1}"
msgstr ""

The difference I'm seeing is that other parsers will create a new line everytime it finds a \n and create a msgid "" or msgstr "" to indicate that the translation is defined by multilines. Here, in the PoExtrator we always use a Single line definition which is not an issue but a difference with other tools.

Explanation here:
https://www.gnu.org/software/gettext/manual/html_node/Normalizing.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants