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

update-po: Doesn't preserve / create X-Domain header of .pot file #365

Open
2 tasks done
FabianKielmann opened this issue Jun 18, 2023 · 3 comments
Open
2 tasks done

Comments

@FabianKielmann
Copy link

Bug Report

Describe the current, buggy behavior

When creating a pot file from your wordpress files and then use wp i18n update-po to update your .po files: In case your .po file is empty, the update-process in general works, but the X-Domain header present in the .pot file will not be included.

Describe how other contributors can replicate this bug

  • create an empty .po file in your language folder
  • create a .pot file with wp i18n make-pot and make sure it added an X-Domain header containing your text-domain
  • update your empty .po file from your .pot file you just created with wp i18n update-po

Describe what you would expect as the correct outcome

I would expect the X-Domain header to be present in the updated .po file in case that the .pot file included it.

Let us know what environment you are running this on

OS:     Linux 5.15.49-linuxkit-pr #1 SMP PREEMPT Thu May 25 07:27:39 UTC 2023 aarch64
Shell:
PHP binary:     /usr/local/bin/php
PHP version:    8.0.29
php.ini used:
MySQL binary:   /usr/bin/mysql
MySQL version:  mysql  Ver 15.1 Distrib 10.6.14-MariaDB, for Linux (aarch64) using readline 5.1
SQL modes:
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       /var/www/html
WP-CLI packages dir:
WP-CLI cache dir:       /home/www-data/.wp-cli/cache
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.8.1

Provide a possible solution

I took a look inside the code and found that the update-po command may use a "wrong" strategy or might just not tell mergewith how to handle the headers:

https://github.com/wp-cli/i18n-command/blob/main/src/UpdatePoCommand.php#L71

@swissspidy
Copy link
Member

Curious: What‘s a use case where the po file doesn‘t have that header but the pot file does? How are you generating the po file?

@FabianKielmann
Copy link
Author

In our case, we just create an empty one.

As far as I know there is no default way of creating a .po file, right? So the first file we ever create (for a plugin for example) would be just an empty .po file which will then get updates from the .pot file that we generate via wp i18n make-json.

@FabianKielmann FabianKielmann changed the title update-po: Doesn't preserve for X-Domain header of .pot file update-po: Doesn't preserve / create X-Domain header of .pot file Jun 19, 2023
@swissspidy
Copy link
Member

As far as I know there is no default way of creating a .po file, right?

You could just copy yourcatalog.pot to yournewpofile.po and you have one :-)

Afterwards, whenever the .pot file is updated, that's when you'd want to use the update-po command.

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

No branches or pull requests

2 participants