roots / sage

WordPress starter theme with Laravel Blade components and templates, Tailwind CSS, and a modern development workflow
https://roots.io/sage/
MIT License
12.75k stars 3.06k forks source link

Include `theme.json`; `patterns/` in translation scan command #3076

Closed strarsis closed 10 months ago

strarsis commented 2 years ago

It turns out that when using --include with wp i18n the theme.json file and the patterns directory need to be explicitly included, too, as those would be skipped otherwise.

Edit: The latest wp i18n version (>=2.4.0) is needed for some bugfixes of otherwise blocking bugs. Until wp CLI is also newly released with the new wp i18n version bundled, the latest wp i18n version can be installed independently from the wp CLI version by using wp package install wp-cli/i18n-command:dev-main and then just using it as usual (wp i18n). Edit (October 2023): Current stable wp cli 2.8.1 contains a recent enough wp i18n.

strarsis commented 2 years ago

With recent bud the theme.json can also be generated by bud (which is the case by default). For having an up-to-date theme.json scanned by wp i18n, the build npm script must run before the translate:pot (or invoked by it) command. Or a separate script that makes bud regenerate only the theme.json could be added that can be invoked before translate:pot (or by it).

strarsis commented 1 year ago

@retlehs: Latest stable WP CLI appears to work fine with the used commands now, so this can be merged.

To make this more robust, bud should re-generate the theme.json before the translate:pot script. This can be achieved by just calling the build script, but wouldn't be just re-generating the theme.json be better than building the whole project? Then bud needs a dedicated command that just re-generates the theme.json (when theme.json generation is enabled in bud, otherwise it can be a no-op).

strarsis commented 1 year ago

@kellymears: A dedicated command for bud that only/specifically re-generates the theme.json (or no-op if no theme.json generation is enabled) would be great for this! That command would run before the translation scan, for the translation source strings in the theme.json being up-to-date.

strarsis commented 1 year ago

@retlehs, @kellymears: Current stable wp cli 2.8.1 contains a recent enough wp i18n, so this PR can be merged now!