Skip to content

In-plugin shortcode/hooks help, fix block JS translations, and translate all locales#49

Merged
erseco merged 9 commits into
mainfrom
feat/in-plugin-help-and-block-i18n
Jun 3, 2026
Merged

In-plugin shortcode/hooks help, fix block JS translations, and translate all locales#49
erseco merged 9 commits into
mainfrom
feat/in-plugin-help-and-block-i18n

Conversation

@erseco
Copy link
Copy Markdown
Contributor

@erseco erseco commented Jun 3, 2026

Closes #48.

1. Fix untranslated Gutenberg block strings

The block sidebar showed "Download options", "Show download button", "Available formats" and the format labels ("Download .elpx", "Web (_web.zip)", etc.) in English even under a translated locale.

  • Root causes: the format labels were referenced through a variable (__( fmt.labelKey, ... )) so wp i18n make-pot could not extract them; and the block used a manual wp.i18n.setLocaleData() injection list (inject_block_translations()) that omitted the newer download strings.
  • Fix: the format labels are now literal __() calls, and the block uses the standard wp_set_script_translations( 'exelearning-elp-block', 'exelearning', …/languages ). The manual injection method is removed.

2. i18n pipeline

  • update-po now updates all locale .po files (previously only es_ES).
  • The source references (#:) are kept (removed the pot-remove-refs step) because wp i18n make-json needs them to map strings to assets/js/elp-upload.js.
  • Added a make-json step (and make json target) that generates the per-locale exelearning-{locale}-{md5}.json files the block loads. The check-untranslated gate now verifies every shipped locale.

3. In-plugin help

  • A Help card on Settings → eXeLearning: shortcode usage, an attribute table, the shortcode filter names, and links to docs/SHORTCODES.md / docs/HOOKS.md.
  • A == Frequently Asked Questions == section in readme.txt (shown on the WordPress.org listing and the in-admin "View details" modal).

4. Translations — all 10 locales

Every shipped locale (ca, ca_valencia, de_DE, eo, es_ES, eu, gl_ES, it_IT, pt_PT, ro_RO) is now fully translated — this also catches up the non-Spanish locales, which had fallen behind and were missing the styles/download feature strings entirely. Non-Spanish translations are best-effort and welcome native-speaker review.

Testing

  • New tests: AdminSettingsTest (help card renders + doc links) and BlockTranslationsTest (the es_ES JS JSON exists and carries the download/format strings; the block uses wp_set_script_translations and no longer uses the manual injection).
  • make lint clean, make phpmd clean.
  • Full make test: 682 tests pass; the only failure is the pre-existing, unrelated StaticEditorInstallerTest::test_is_editor_installed_returns_false_when_missing (also fails on main in this local env, where the static editor is installed).
  • The generated exelearning-es_ES-<md5>.json uses md5('assets/js/elp-upload.js'), which matches WordPress core's resolution for the registered script handle.
  • msgattrib --untranslated returns nothing for every locale.

Recommended manual check: open the block editor under a Spanish locale and confirm the Download options panel and format checkboxes render translated.

erseco added 4 commits June 3, 2026 17:41
The block sidebar download strings and format labels rendered untranslated.
Two root causes: the format labels were referenced via a variable
(__( fmt.labelKey )) so wp i18n make-pot could not extract them, and the
block relied on a manual setLocaleData() injection list that omitted the
newer download strings.

- Make the format labels literal __() calls so they are extractable.
- Register translations with wp_set_script_translations() and remove the
  manual inject_block_translations() machinery.
- i18n pipeline: update all locale .po files (not just es_ES), keep the
  source references (needed by make-json), and add a make-json step that
  generates the per-locale JS translation JSON the block now loads.
Surface a lightweight shortcode/hooks reference inside WordPress: a Help card
on Settings -> eXeLearning (usage, attribute table, hook names, links to the
GitHub docs) and a Frequently Asked Questions section in readme.txt.
Catch up every locale (ca, ca_valencia, de_DE, eo, es_ES, eu, gl_ES, it_IT,
pt_PT, ro_RO) so no shipped language has untranslated strings, and add the
generated exelearning-{locale}-{md5}.json files loaded by the block.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

Test in WordPress Playground

Test the plugin with the code from this branch:

Preview in WordPress Playground

⚠️ The embedded eXeLearning editor is not included in this preview. You can install it from Settings > eXeLearning using the "Download & Install Editor" button. All other plugin features (ELP upload, shortcode, Gutenberg block, preview) work normally.

erseco added 5 commits June 3, 2026 18:02
The GitHub runner's bundled wp-cli does not accept make-json's --no-purge
flag. JSON generation is not needed for the translation-completeness gate;
keep it as the standalone 'make json' target. The committed JSON artifacts
are guarded by BlockTranslationsTest.
Render each example as its own block <code> element instead of a single
<pre> block, whose first line inherited the PHP source indentation.
The block script was registered with plugins_url('../assets/js/elp-upload.js',
__FILE__), producing an unnormalized 'includes/../assets/js/elp-upload.js' URL.
wp_set_script_translations() derives the JSON filename from md5 of that path,
which did not match the make-json output (md5 of 'assets/js/elp-upload.js'), so
no block strings were translated. Register with the plugin-root file as base so
the URL is clean and the md5 matches.

Strengthen BlockTranslationsTest to assert WordPress actually resolves the
translations (would have caught this), and reset the scripts/styles registries
in tear_down so the enqueue does not leak into other test classes.
The dashicons-edit glyph rendered misaligned inside the button in newer
WordPress; the buttons read clearly without it.
@erseco erseco merged commit 1fbcde8 into main Jun 3, 2026
4 checks passed
@erseco erseco deleted the feat/in-plugin-help-and-block-i18n branch June 3, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Surface shortcode/hooks help in-plugin and fix Gutenberg block JS translations

1 participant