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

PHP extractor misses plural strings that use brackets in their discriminator #295

Closed
2 tasks done
NielsdeBlaauw opened this issue Dec 16, 2021 · 3 comments
Closed
2 tasks done

Comments

@NielsdeBlaauw
Copy link

NielsdeBlaauw commented Dec 16, 2021

Bug Report

Describe the current, buggy behavior
When running make-pot the i18n commando can not correctly extract plurals when there brackets in the discriminator.

This is much like #225, but for PHP.

The reproduction example below is a minimal reproduction. The original case for us was code generated by Twig, which looks like

echo sprintf(_n("Reading time: %s minute", "Reading time: %s minutes", ($context['x'] ?? null), "demo"), ($context['x'] ?? null));

Describe how other contributors can replicate this bug

  1. Create a php file with the following two string:
echo sprintf(_n("Reading time: %s minute", "Reading time: %s minutes", (1), "demo"), 1);
echo sprintf(_n("Download time: %s minute", "Download time: %s minutes", 1, "demo"), 1));
  1. run wp i18n make-pot
  2. Check resulting pot file. Download time is available to translate. Reading time is not.

Describe what you would expect as the correct outcome
The resulting pot file should contain both Reading time and Download Time.

@swissspidy
Copy link
Member

This is a known bug in the underlying gettext library we're using for extracting the function calls: php-gettext/Gettext#229

It might not a bug in v5, but we're still on v4 due to PHP version requirements.

@settings settings bot removed the blocked label Jan 6, 2022
@swissspidy
Copy link
Member

It might be possible to fix this upstream in v4, but needs someone to write a PR.

@swissspidy
Copy link
Member

Since this is blocked by the upstream library and an easy workaround exists, I am closing this one for now

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