Skip to content

Load language packs from TranslationsPress - #804

Merged
ilicfilip merged 2 commits into
developfrom
taco/translationspress-language-packs
Nov 17, 2026
Merged

ilicfilip merged 2 commits into
developfrom
taco/translationspress-language-packs

Conversation

@tacoverdo

Copy link
Copy Markdown
Contributor

Why

The plugin is no longer distributed through WordPress.org, so WordPress finds no language packs for it there. Every site that doesn't already have a pack shows the plugin in English, and existing packs never update.

TranslationsPress already builds language packs for the plugin and publishes them at https://packages.translationspress.com/progress-planner/progress-planner/packages.json.

What

A new Progress_Planner\Translations class hooks pre_set_site_transient_update_plugins and adds our language packs to the translations list WordPress keeps with its plugin update data. From there WordPress core does the rest: the packs show under Dashboard → Updates, install with automatic translation updates, land in wp-content/languages/plugins/, and load just in time. The text domain is unchanged.

  • Which locales: the languages installed on the site, the same set WordPress asks WordPress.org about.
  • When a pack is offered: when no translation is installed for that locale, or the pack's updated date is newer than the installed file's PO-Revision-Date.
  • Remote requests: the feed is fetched only while WordPress stores the result of a plugin update check, never on a normal page load. It is cached for 12 hours, and a failure for 1 hour.
  • Hardening: a pack is ignored unless its URL starts with our own TranslationsPress project URL, because WordPress downloads and unpacks that file.
  • Existing packs: an older WordPress.org entry for the same locale is replaced, so the list never holds two packs for the same files.

Testing

  • New Translations_Test (13 tests): offering a pack, the installed-date comparison, keeping other plugins' updates, no duplicates on a second run, rejecting foreign package URLs, and caching of success and failure responses.
  • Full PHPUnit suite (472 tests), phpcs, PHPStan and the syntax lint pass locally.
  • End to end on a scratch WordPress 7.1.4 install with the real feed: after wp_update_plugins(), core listed one translation update for nl_NL, Language_Pack_Upgrader installed it, a fresh request rendered "Recommendations" as "Aanbevelingen", and a second update check no longer offered the pack.

Notes for the reviewer

  • The feed currently has only nl_NL. Its metadata says version 1.9.1, updated 2026-02-20, but the zip it serves contains 1.10.x strings and a PO-Revision-Date of today. The comparison uses the feed's updated date, so a site that already has a pack newer than that date is not offered the TranslationsPress one until the feed's date advances.
  • A pack is installed on the next update check, not at activation.
  • No changelog entry is included; there is no unreleased section in readme.txt / CHANGELOG.md yet.

🤖 Generated with Claude Code

The plugin is no longer distributed through WordPress.org, so WordPress
finds no language packs for it there. Offer the packs TranslationsPress
builds for the plugin as translation updates instead. WordPress then
downloads, installs and loads them as it did before.

The list of packs is fetched only while WordPress stores the result of a
plugin update check, and is cached for 12 hours (1 hour after a failure).
Only packages hosted in our own TranslationsPress project are accepted.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Test merged PR on Playground
Test this pull request on the Playground
or download the zip

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

✅ Code Coverage Report

Metric Value
Total Coverage 35.07% 📉
Base Coverage 34.52%
Difference 📈 0.55%

⚠️ Coverage below recommended 40% threshold

🎉 Great job maintaining/improving code coverage!

📊 File-level Coverage Changes (2 files)

🆕 New Files

Class Coverage Lines
🟢 Progress_Planner\Translations 93.42% 71/76

📈 Coverage Improved

Class Before After Change
Progress_Planner\Base 49.69% 50.00% +0.31%
ℹ️ About this report
  • All tests run in a single job with Xdebug coverage
  • Security tests excluded from coverage to prevent output issues
  • Coverage calculated from line coverage percentages

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🔍 WordPress Plugin Check Report

⚠️ Status: Passed with warnings

📊 Report

🎯 Total Issues ❌ Errors ⚠️ Warnings
10 0 10

⚠️ Warnings (10)

📁 classes/suggested-tasks/data-collector/class-unpublished-content.php (1 warning)
📍 Line 🔖 Check 💬 Message
103 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://docs.wpvip.com/databases/optimize-queries/using-post__not_in/ for more information.
📁 classes/suggested-tasks/providers/class-content-review.php (4 warnings)
📍 Line 🔖 Check 💬 Message
232 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://docs.wpvip.com/databases/optimize-queries/using-post__not_in/ for more information.
377 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://docs.wpvip.com/databases/optimize-queries/using-post__not_in/ for more information.
381 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://docs.wpvip.com/databases/optimize-queries/using-post__not_in/ for more information.
388 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://docs.wpvip.com/databases/optimize-queries/using-post__not_in/ for more information.
📁 classes/activities/class-query.php (2 warnings)
📍 Line 🔖 Check 💬 Message
71 PluginCheck.Security.DirectDB.UnescapedDBParameter Unescaped parameter $table_name used in $wpdb->query()\n$table_name assigned unsafely at line 58.
163 PluginCheck.Security.DirectDB.UnescapedDBParameter Unescaped parameter $where_args used in $wpdb->get_results()\n$where_args assigned unsafely at line 153.
📁 classes/suggested-tasks/data-collector/class-terms-without-description.php (1 warning)
📍 Line 🔖 Check 💬 Message
108 PluginCheck.Security.DirectDB.UnescapedDBParameter Unescaped parameter $query used in $wpdb->get_results()\n$query assigned unsafely at line 106.
📁 classes/suggested-tasks/data-collector/class-yoast-orphaned-content.php (1 warning)
📍 Line 🔖 Check 💬 Message
111 PluginCheck.Security.DirectDB.UnescapedDBParameter Unescaped parameter $query used in $wpdb->get_row()\n$query assigned unsafely at line 98.
📁 classes/suggested-tasks/data-collector/class-terms-without-posts.php (1 warning)
📍 Line 🔖 Check 💬 Message
120 PluginCheck.Security.DirectDB.UnescapedDBParameter Unescaped parameter $query used in $wpdb->get_results()\n$query assigned unsafely at line 118.

🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@tacoverdo

Copy link
Copy Markdown
Contributor Author

The failing test check (WordPress.org Plugin Check) is expected and left as is.

Plugin Check reports one error in classes/class-translations.php:

plugin_updater_detected — Plugin Updater detected. These are not permitted in WordPress.org hosted plugins.

It triggers on the pre_set_site_transient_update_plugins hook. That hook is the feature: telling WordPress about language packs from another source always goes through the plugin update data, so there is no rewrite that avoids the rule. The two update_modification_detected warnings on the same file have the same cause.

The rule exists for plugins hosted on WordPress.org, which this plugin no longer is. The check could be made green by adding plugin_updater to exclude-checks in .github/workflows/plugin-check.yml, but that would relax the gate for the whole repository, so it is deliberately not done in this PR. If the plugin ever returns to WordPress.org, this class has to be removed again.

All other checks pass. The first failure of this job was unrelated: the dist-archive-command install step failed to authenticate against GitHub, and a re-run got past it.

🤖 Posted by Claude Code

The TranslationsPress language packs hook pre_set_site_transient_update_plugins,
which Plugin Check reports as plugin_updater_detected and
update_modification_detected. That rule is for plugins hosted on WordPress.org,
and this plugin was closed there on 2026-10-26. Ignore only those two codes so
the rest of the check keeps running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ilicfilip

Copy link
Copy Markdown
Collaborator

Reviewed, with one change pushed in 842386a. Plugin Check is green now, and so is the rest of CI.

What changed: Plugin Check ignores only the two updater codes.
Agreed that the hook can't be avoided and that excluding the whole plugin_updater check is too broad. Leaving the check red has its own cost, though: every later PR to develop would show this failure, and a real Plugin Check problem would get lost in it. plugin-check-action v1.1.9 has an ignore-codes input, so .github/workflows/plugin-check.yml now ignores only plugin_updater_detected and update_modification_detected. The rest of the plugin_updater check still runs. A comment in the workflow points to classes/class-translations.php and says to remove both lines if the plugin returns to WordPress.org.

Checked, no change needed:

  • Feed dates: TranslationsPress has rebuilt the feed. nl_NL is now 1.10.1, updated 2026-11-16T15:47:26+00:00, and that matches the PO-Revision-Date inside the zip exactly. The mismatch in the PR description is gone, so the date comparison works with the real feed.
  • WordPress.org: the plugin was closed there on 2026-10-26. The update-check API core uses returns nothing for progress-planner, while Akismet's nl_NL pack comes back in the same request. So WordPress.org can't offer a pack that competes with the TranslationsPress one, and the removal of old entries doesn't need to cover the case where our pack is skipped.
  • End to end on a local WordPress 7.1.4 site with this branch: the update check offers only the TranslationsPress nl_NL pack. "Update Translations" on Dashboard → Updates installs it, the Progress Planner dashboard renders in Dutch with a clean console, and a second update check doesn't offer the pack again.

Follow-up outside this PR: WordPress.org still lists packs for da_DK, es_CL and es_ES, but core no longer offers them, and TranslationsPress only has nl_NL. Sites in those languages keep their last installed pack until TranslationsPress has those languages too.

@ilicfilip
ilicfilip merged commit ea00838 into develop Nov 17, 2026
22 checks passed
@ilicfilip
ilicfilip deleted the taco/translationspress-language-packs branch November 17, 2026 10:03
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.

2 participants