-
Notifications
You must be signed in to change notification settings - Fork 50
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
Issues parsing PO files without empty lines #393
Comments
HI there, thanks for reaching out! From what I can see after a quick test, the issue is that your PO files do not contain any empty lines between the strings, just empty comments. Example: #
# File: eme-actions.php, line: 343
# File: eme-events.php, line: 9395
msgid "An error has occurred"
msgstr "Es ist ein Fehler aufgetreten"
#
# File: eme-actions.php, line: 344
msgid "Clear"
msgstr "Leeren"
#
# File: eme-actions.php, line: 345
# File: eme-events.php, line: 9396
msgid "Mailing preferences"
msgstr "Mailing Präferenzen"
#
# File: eme-actions.php, line: 346
# File: eme-events.php, line: 9397
msgid "Yes, I'm sure"
msgstr "Ja, ich bin mir sicher" Where it should be:
That seems to confuse our PO parser, which then ends up not extracting any strings—or well, just one, with all other strings being added as comments. So how did you generate those PO files? 🤔 The headers say Poedit, but Poedit properly adds spaces. So did you modify them manually or something? A quick way to fix this would be:
It's |
In fact most po-files come from the wordpress translation site (before I moved to github), the french version is maintained by another person (I get github pull requests) but I presume it is poedit too. It's not like I maintain all files :-)
So I'm assuming msgmerge knows what it does and the empty lines are not a requirement :-) Concerning "wp cli info" ==> I got confused by the "wp cli" part, but it seems "cli" is also a subcommand :-) Obfuscated output:
|
Hmm I see, interesting! Well, I'll need to check whether the whitespace thing can be easily resolved in the third-party gettext library we're using, or if we can work around it somehow. In the meantime, I suggest using the |
I dug little deep into the plugin provided by the OP then I found that the custom script to generate POT file https://github.com/liedekef/events-made-easy/blob/main/langs/gettextize.sh.orig is actually eating the blank line between the translation entry. General standard for translation entry is following which expects one blank line between translation entry and this is been followed by all PO/POT generators.
So I doubt upstream gettext library will update to parse the POT file which does not adhere the standard. |
Sorry, but this is not correct. I explained the steps to reproduce above (without my shell script), but will repeat them:
No use of any script, just msgmerge (binary provided by the gettext rpm on fedora). I can reproduce this every time. |
As per my previous comment, I wanted to look into it a bit more. This was a nice little push now :) I just submitted a PR upstream to the Gettext library (php-gettext/Gettext#296) now to address this. There is no guarantee that it is accepted though, as we're using an older version of the library because of PHP requirements.
|
Thanks, it sems you had more work with the test-files than the actual code change there :-) |
I thought we fixed this a while ago. Are you sure you're using the latest version of the command? Update to WP-CLI nightly just in case. |
|
I updated to nightly: that fixes this mentioned php-issue. So the released version still has the bug in it. |
Well, yes and no. A new version of this command was already tagged, so you can install it with
That's strange. This option is "update def.po, do nothing if def.po already up to date". So maybe nothing was updated in your case? |
PO file is being updated with new string from the main POT file. |
@liedekef I have created a POC pull request to use WPCLI i18n commands for updating PO files and regenerating mo files. You can take this as reference and modify according to your requirement. liedekef/events-made-easy#553 |
Well, I already have a script in the language subdir that does the same (without composer of course):
And since I currently need the nightly wp-cli build to fix a php-bug, I'll stay with my script for now :-) |
Alright, so new versions of the Gettext library were released. wp-cli/wp-cli-bundle#639 updates the library for the bundle, which means after merge the next WP-CLI nightly build should have the new version. Closing this as nothing needs to be done in this repo. |
Bug Report
Describe the current, buggy behavior
When using the normal wp-includes/pomo to create a pot-file, and then msgmerge and msgfmt, all pot/po and mo files are generated/merged as expected. However, when using "wp-cli" there are a number of issues:
The source language files in question are from my plugin and can be found here: https://github.com/liedekef/events-made-easy/tree/main/langs
So it seems that some header is missing/required by the i18n-commands that isn't marked. I get no errors when creating the po/mo/php files (just the usual "Success: ..." output). I tried copying the headers from the nl_BE po-file to the fr-counterpart but to no avail.
Describe what you would expect as the correct outcome
Correctly generated po/mo/php files, or at least some error indicating the issue with the po-files.
Let us know what environment you are running this on
The text was updated successfully, but these errors were encountered: