Giter Club home page Giter Club logo

Comments (11)

remcotolsma avatar remcotolsma commented on September 2, 2024 4

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.

swissspidy avatar swissspidy commented on September 2, 2024 1

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.

dgwyer avatar dgwyer commented on September 2, 2024 1

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.

remcotolsma avatar remcotolsma commented on September 2, 2024 1

It might be good to know that this seems to work well on PHP 7.4, but it goes wrong in PHP 8.

A workaround is to run wp i18n make-pot on PHP 7.4:

brew link --overwrite [email protected]

from i18n-command.

swissspidy avatar swissspidy commented on September 2, 2024 1

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.

swissspidy avatar swissspidy commented on September 2, 2024 1

Working on adding a test here: #344

Updating the dependency here:

from i18n-command.

remcotolsma avatar remcotolsma commented on September 2, 2024

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:

'__' => 'text_domain',
'esc_attr__' => 'text_domain',
'esc_html__' => 'text_domain',
'esc_xml__' => 'text_domain',
'_e' => 'text_domain',
'esc_attr_e' => 'text_domain',
'esc_html_e' => 'text_domain',
'esc_xml_e' => 'text_domain',
'_x' => 'text_context_domain',
'_ex' => 'text_context_domain',
'esc_attr_x' => 'text_context_domain',
'esc_html_x' => 'text_context_domain',
'esc_xml_x' => 'text_context_domain',
'_n' => 'single_plural_number_domain',
'_nx' => 'single_plural_number_context_domain',
'_n_noop' => 'single_plural_domain',
'_nx_noop' => 'single_plural_context_domain',

from i18n-command.

swissspidy avatar swissspidy commented on September 2, 2024

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.

remcotolsma avatar remcotolsma commented on September 2, 2024

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.

swissspidy avatar swissspidy commented on September 2, 2024

Yes it's quite possible, but we cannot use the newer version yet because of PHP version requirements.

from i18n-command.

remcotolsma avatar remcotolsma commented on September 2, 2024

ℹ️ 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.