Closed dac514 closed 5 years ago
How are you currently extracting strings from your files? Do you perhaps have a link to your project?
The original goal was to make it easy to extract strings in a similar fashion to the old makepot script, which is only concernced with "regular" PHP files, and to add support for the new JS features.
Hi @swissspidy
How are you currently extracting strings from your files? Do you perhaps have a link to your project?
The project is Pressbooks: https://github.com/pressbooks/pressbooks/tree/dev/languages
We use wp-cli to generate the .pot source files. Note: We run your branch for plurals. We do:
wp i18n make-pot . languages/<plugin>.pot --exclude="vendor,symbionts" --headers='{"Report-Msgid-Bugs-To":"https://github.com/pressbooks/<plugin>/"}'
We then send the generated files to Transifex: https://github.com/pressbooks/pressbooks/blob/dev/bin/i18n.sh
Here's a hack at getting it working with Blade templates. I don't think it's a good idea. https://github.com/pressbooks/pressbooks/pull/1616
The original goal was to make it easy to extract strings in a similar fashion to the old makepot script, which is only concernced with "regular" PHP files, and to add support for the new JS features.
Yes, I understand this, (after the fact). I'm at the point where either either Blade templates (could) work with wp i18n
or i'm going to convert them to plain php files and pull the plug on Blade in our project.
Thanks!
We're still trying to work out how best to extend bundled commands like wp i18n
. Ideally, I think you should be able to provide a separate third-party package that extends the wp i18n
command to be able to support Blade templates.
To actually make this work, I think the best approach would be to just pull in the BladeCompiler class, compile into regular PHP and then provide it to the regular parser.
Thanks for the tip @schlessera. I overrode WP_CLI\I18n\MakePotCommand
and got it working in our project.
Commit is here: https://github.com/pressbooks/pb-cli/commit/afe5bb1842dd1660076d657504871f1476b60084
Closing bug.
There is now this PR for supporting Blade template extraction: #304
Currently, this CLI command supports PHP and two types of JavaScript extraction. Eventually, the code that does this leads back to / depends on: Gettext\Extractors\PhpCode and Gettext\Utils\JsFunctionsScanner
oscarotero/Gettext
supports several other extractors, one of them is Blade templates.Our WordPress project uses Blade templates. The naming convention for Blade templates is:
/path/to/name.blade.php
The strings inside those files looks like:{{ __( 'My English string', 'my-plugin-name' ) }}
The i18n-command finds, scans, and fails to extract anything meaningful from those files.Please support Blade templates. I'm willing to write a PR to do this if this issue isn't closed as a #wontfix.
Related: https://github.com/wp-cli/i18n-command/issues/52