In-plugin shortcode/hooks help, fix block JS translations, and translate all locales#49
Merged
Merged
Conversation
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.
Contributor
Test in WordPress PlaygroundTest the plugin with the code from this branch:
|
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.
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.
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.
__( fmt.labelKey, ... )) sowp i18n make-potcould not extract them; and the block used a manualwp.i18n.setLocaleData()injection list (inject_block_translations()) that omitted the newer download strings.__()calls, and the block uses the standardwp_set_script_translations( 'exelearning-elp-block', 'exelearning', …/languages ). The manual injection method is removed.2. i18n pipeline
update-ponow updates all locale.pofiles (previously onlyes_ES).#:) are kept (removed thepot-remove-refsstep) becausewp i18n make-jsonneeds them to map strings toassets/js/elp-upload.js.make-jsonstep (andmake jsontarget) that generates the per-localeexelearning-{locale}-{md5}.jsonfiles the block loads. Thecheck-untranslatedgate now verifies every shipped locale.3. In-plugin help
Settings → eXeLearning: shortcode usage, an attribute table, the shortcode filter names, and links todocs/SHORTCODES.md/docs/HOOKS.md.== Frequently Asked Questions ==section inreadme.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
AdminSettingsTest(help card renders + doc links) andBlockTranslationsTest(the es_ES JS JSON exists and carries the download/format strings; the block useswp_set_script_translationsand no longer uses the manual injection).make lintclean,make phpmdclean.make test: 682 tests pass; the only failure is the pre-existing, unrelatedStaticEditorInstallerTest::test_is_editor_installed_returns_false_when_missing(also fails onmainin this local env, where the static editor is installed).exelearning-es_ES-<md5>.jsonusesmd5('assets/js/elp-upload.js'), which matches WordPress core's resolution for the registered script handle.msgattrib --untranslatedreturns 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.