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

Problem with CSV2PO conversion #11

Closed
norbou2 opened this issue Aug 16, 2022 · 4 comments · Fixed by #13
Closed

Problem with CSV2PO conversion #11

norbou2 opened this issue Aug 16, 2022 · 4 comments · Fixed by #13

Comments

@norbou2
Copy link

norbou2 commented Aug 16, 2022

Hi Marek,
at first big thanks for this lifehack! It works nice and it is my first Node.JS app, whch I have ever run :-)
In most cases recoding PO works well, I had some problem with conversion translated CSV of the MLA plugin back to PO.
https://translate.wordpress.org/projects/wp-plugins/media-library-assistant/
Probably there is an error on the PO, but Poedit validate it as without problems.
77 IDs translation was not decoded from CSV to PO, for example [list_table_column] Slug.
They all had in common that they had a named component before the string itself, or plural and singular was defined. The problem also occurred if I did not delete the MSGID "All".

https://ibb.co/drJ0BbG

With best regards,
Jiri

@marek-saji
Copy link
Owner

@norbou2 Hi 🙂 Could you attach a minimal file that causes the error? Ideally as small as possible, only with one or two translations.

@norbou2
Copy link
Author

norbou2 commented Aug 20, 2022

Hi Marek,
I thing any field with defined msgctxt I had to backfill using PO synchronization and translate additionally in Poedit. It was 77 items.

But let's focus on this record:
node index.js test.po test.csv 1>test-translated.po
Error: msgid_plural mismatch for "All"
at d:\Downloads\po-csv-master\index.js:180:23
at Array.forEach ()
at d:\Downloads\po-csv-master\index.js:172:22
at Array.forEach ()
at mergeIntoPo (d:\Downloads\po-csv-master\index.js:171:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

This record at row 5962 has to be deleted to complete the conversion:

#: includes/class-mla-list-table.php:1822
msgctxt "uploaded files"
msgid "All"
msgid_plural "All"
msgstr[0] "Všechny"
msgstr[1] "Všechny"
msgstr[2] "Všechny"

CSV:
All,All,,includes/class-mla-list-table.php:1822,,,Všechny,Všechny,Všechny

After deletion line on CSV is conversion completed.

And.. woila... when I open original and reparsed po file, both has 1243 strings and all of them are translated :-) Ok, probably I deleted something wrong during first processing, even though I've done it twice. Let's compare PO files in differences.

Records containging msgctxt value are converted well:
#: includes/class-mla-settings-shortcodes-tab.php:2005
msgctxt "table_view_plural"
msgid "Term List"
msgstr "Seznam pojmů"

The only difference id merging of multiple string with line breaks into one string, what is nice feature I think!

But I had noticed, that also this delcaration has changed:
"Plural-Forms: nplurals=3; plural=(n == 1) ? 0 : ((n >= 2 && n <= 4) ? 1 : "
"2);\n"
"Plural-Forms: nplurals=3; plural=(n == 1) ? 0 : ((n >= 2 && n <= 4) ? 1 : 2);\n"

So the only question is about msgid "All" now.

When I deleted all other records, the problem is not reproducible and the conversion works without any error...

@marek-saji
Copy link
Owner

@norbou2 I think the problem was that CSV files did not include msgctxt at all. I've published a prerelease version which will start doing so. Could you test it on your file to verify if it works correctly?

Depending on how you used po-csv:

@norbou2
Copy link
Author

norbou2 commented Sep 15, 2022

Hi Marek,
that's perfect, it works great now with large MLA po file downloaded from https://translate.wordpress.org/projects/wp-plugins/media-library-assistant/. 👏

Thank you very much!
Jiri

@norbou2 norbou2 closed this as completed Sep 15, 2022
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