Re-extract POT to include recycle-bin and posts-window strings#107
Open
Re-extract POT to include recycle-bin and posts-window strings#107
Conversation
The shipped JSON bundle was named
`desktop-mode-es_ES-wp-desktop.json`, a leftover from the plugin's
old `wp-desktop` slug. WordPress derives JS translation filenames
as `{textdomain}-{locale}-{handle}.json` and we now register three
handles (desktop-mode, desktop-mode-recycle-bin,
desktop-mode-posts-window), none of which is `wp-desktop`, so the
file was orphaned and JS strings rendered untranslated for es_ES.
Rename the bundle to the handle WordPress actually looks for
(`desktop-mode-es_ES-desktop-mode.json`). The recycle-bin and
posts-window bundles have no PO entries yet (those source files
postdate the last POT extraction), so no JSON ships for them.
Add bin/build-i18n.sh (and its bin/build-i18n-merge.php helper)
so future locales regenerate the right filenames automatically.
The script invokes `wp i18n make-json --extensions=ts` and merges
the per-source JSONs into one per-handle JSON using a prefix map
that points each script handle at its source tree. Wire it up as
`npm run build:i18n` and document the flow in docs/DEVELOPMENT.md.
Fixes #96
The POT was last extracted before src/recycle-bin/ and src/posts-window/
landed, so the 136 __()/_x() calls in those bundles were never
translatable. Re-extracted to bring them in.
Extraction pipeline:
1. wp i18n make-pot . languages/desktop-mode.pot --skip-js \
--slug=alcazaba-plugin --package-name="Desktop Mode" \
--headers='{"Report-Msgid-Bugs-To":"https://wordpress.org/support/plugin/alcazaba-plugin"}'
(PHP-only pass; wp-cli's JS extractor is .js/.jsx-only and chokes on
TypeScript syntax.)
2. xgettext --language=TypeScript --keyword=__:1 --keyword=_x:1,2c \
--keyword=_n:1,2 --keyword=_nx:1,2,4c --add-comments=translators \
--no-wrap (run over every src/**/*.ts excluding tests) into a
temporary POT.
3. msgcat --no-wrap --use-first to merge the TS strings into the wp-cli
POT, keeping the wp-cli header.
4. msgmerge --no-wrap --update languages/desktop-mode-es_ES.po against
the new POT. msgfmt to refresh the .mo.
5. npm run build:i18n to regenerate per-handle JSON files. New files
shipped: desktop-mode-es_ES-desktop-mode-recycle-bin.json (11 strings)
and desktop-mode-es_ES-desktop-mode-posts-window.json (85 strings).
The desktop-mode handle JSON now has 156 strings (up from 79).
POT msgid count: 140 -> 396. New strings are untranslated for now,
English fallback continues to work for them.
Closes #104
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
__()/_x()calls insidesrc/recycle-bin/andsrc/posts-window/become translatable.msgmergelanguages/desktop-mode-es_ES.poagainst the new POT, refresh the.mo, and regenerate per-handle JSON vianpm run build:i18n(added in PR Fix JS translations filename for the desktop-mode handle #100).Changes
languages/desktop-mode.pot: 140 → 396 msgids (256 new), including 120 references undersrc/recycle-bin/andsrc/posts-window/.languages/desktop-mode-es_ES.po: msgmerged. 96 translated, 27 fuzzy, 272 untranslated, 2 obsolete entries flagged (Open new %s,Detach to new tab).languages/desktop-mode-es_ES.mo: regenerated.languages/desktop-mode-es_ES-desktop-mode.json: 79 → 156 strings.languages/desktop-mode-es_ES-desktop-mode-recycle-bin.json: new, 11 strings.languages/desktop-mode-es_ES-desktop-mode-posts-window.json: new, 85 strings.Extraction pipeline (and why)
The "obvious"
wp i18n make-pot . languages/desktop-mode.pot --include='src/*.ts,src/**/*.ts' --skip-jsproduces zero JS-side strings. Two reasons:--skip-jsdisables the JS extractor entirely.--skip-js, wp-cli'sJsCodeExtractoris hardcoded to[js, jsx]extensions only, and its Peast parser chokes on TypeScript syntax (interface, generics,type,as Foo). Renaming.ts→.jsfails for the same Peast reason.What worked (a two-pass extraction merged with
msgcat):wp i18n make-pot . languages/desktop-mode.pot --skip-js --slug=alcazaba-plugin --package-name="Desktop Mode" --headers='{"Report-Msgid-Bugs-To":"https://wordpress.org/support/plugin/alcazaba-plugin"}'(slug preserved to keep this diff focused).xgettext --language=TypeScript --keyword=__:1 --keyword=_x:1,2c --keyword=_n:1,2 --keyword=_nx:1,2,4c --add-comments=translators --no-wrapover every non-testsrc/**/*.tsinto a temp POT (GNU gettext-tools handles TS natively).msgcat --no-wrap --use-first languages/desktop-mode.pot /tmp/ts.pot -o languages/desktop-mode.pot.msgmerge --no-wrap --update --backup=off languages/desktop-mode-es_ES.po languages/desktop-mode.pot.msgfmt languages/desktop-mode-es_ES.po -o languages/desktop-mode-es_ES.mo.npm run build:i18n(from PR Fix JS translations filename for the desktop-mode handle #100).Worth landing this as a documented
bin/build-pot.shin a follow-up so the next contributor doesn't rediscover the wp-cli/Peast TS gap.Verified
npm run buildclean (six bundles built including pwa-sw).npm run lintclean.tsc --noEmitclean.npm run test:js: 803 / 87 files all green.msgfmt --check --statisticspasses.grep -c "src/recycle-bin\|src/posts-window" languages/desktop-mode.potreturns 120 (vs 0 on trunk).Notes
fix/96-js-translations-filename) becausenpm run build:i18nwas added there. When Fix JS translations filename for the desktop-mode handle #100 lands, this PR's diff collapses to a single commit.Open new %s,Detach to new tab) and msgmerge flagged them with#~.src/window/tabs.ts:324: warning: invalid escape sequence in string. Pre-existing source code; not investigated here.Report-Msgid-Bugs-ToURL still saysalcazaba-plugin(the project's old slug). Preserved to keep this PR focused; should be fixed todesktop-modein a separate change.Closes #104