Comments (11)
In any case, it needs a volunteer to submit a PR to the Gettext library to help fix this properly :)
I have come up with a fix and opened a PR:
I don't have much experience with this, but I did my best to contribute.
from i18n-command.
Well that is surprising!
Looks like the PHP functions scanner we're using doesn't properly extract such functions call, so unfortunately this will need to get fixed upstream.
from i18n-command.
Just adding a note here that this isn't likely to be fixed in the Gettext repo any time soon due to time constraints; incase anyone from the wp-cli team is able to pick this up.
php-gettext/Gettext#284 (comment)
from i18n-command.
It might be good to know that this seems to work well on PHP 7.4, but it goes wrong in PHP 8.
- Test on PHP 7.4 → remcotolsma/wp-cli-i18n-make-pot-issue-php-8@41f1280
- Test on PHP 8.1 → remcotolsma/wp-cli-i18n-make-pot-issue-php-8@e89b029
A workaround is to run wp i18n make-pot
on PHP 7.4
:
brew link --overwrite [email protected]
from i18n-command.
Awesome, thanks a lot! And it has been merged, too!
Once a new release of Gettext v4 has been released, we can update the dependency here & update our tests too. Then we should be all set.
from i18n-command.
Working on adding a test here: #344
Updating the dependency here:
from i18n-command.
Maybe it's related to a token_get_all()
change in PHP 8:
https://3v4l.org/48MdV
In PHP 7.4
the function call \__
is split in two tokens \
and __
in PHP 8.0
it's just one token \__
.
In PHP 8.0
there is a new T_NAME_FULLY_QUALIFIED
token:
https://www.php.net/manual/en/tokens.php
It could be fixed by adding T_NAME_FULLY_QUALIFIED
to the following line:
https://github.com/php-gettext/Gettext/blob/207719c6eae36f5ac7c2c9542f6a4d4b76307e5a/src/Utils/PhpFunctionsScanner.php#L101
And by adding fully qualified function names (\__
, \_e
, etc.) to this list:
i18n-command/src/PhpCodeExtractor.php
Lines 17 to 33 in c1beab8
from i18n-command.
Interesting, yeah that might be it. In any case, it needs a volunteer to submit a PR to the Gettext library to help fix this properly :)
from i18n-command.
The https://github.com/php-gettext/Gettext library is already moved on the version 5
and the new https://github.com/php-gettext/PHP-Scanner library uses https://github.com/nikic/php-parser. It is quite possible that https://github.com/nikic/php-parser has better support for fully qualified names (FQN) and the problem is therefore no longer an issue in the latest Gettext library?
from i18n-command.
Yes it's quite possible, but we cannot use the newer version yet because of PHP version requirements.
from i18n-command.
ℹ️ Version 4.8.8
of gettext/gettext
was released yesterday: https://github.com/php-gettext/Gettext/releases/tag/v4.8.8 🎉.
from i18n-command.
Related Issues (20)
- make-pot failing to parse specific JavaScript code HOT 8
- Missing file name and line numbers in POT file HOT 8
- PHP 8.2 - PHP Deprecated: Use of "static" in callables is deprecated in ...i18n-command/src/IterableCodeExtractor.php on line 245/246
- update-po: Doesn't preserve / create X-Domain header of .pot file HOT 3
- sokirka HOT 1
- PHP Warning: mkdir(): Read-only file system in MakePotCommand.php on line 376 HOT 6
- `make-mo`: Add option to specify filename HOT 8
- Add tests verifying generated translation files work as intended
- PHP Warning: foreach() argument must be of type array|object, HOT 3
- Consider adding file reference for strings extracted from file headers
- Document example of how to format the --headers parameter in the `i18n make-pot` command HOT 1
- Are file references for plugin/theme headers supposed to be absolute paths? HOT 1
- wp i18n make-php - Expectations HOT 2
- wp i18n make-pot: Support PHP8 named parameters HOT 1
- Author URI of the plugin translation string in generated POT file HOT 3
- Issues parsing PO files without empty lines HOT 15
- make-php - Make output file content pretty HOT 2
- Incorrect POT license info for themes without a license in the header HOT 1
- PHP deprecated notices in Unit test
- make-pot not working for my project HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from i18n-command.