Post Translation: New plugin for translating post/page content via GlotPress#602
Open
dd32 wants to merge 15 commits intoWordPress:trunkfrom
Open
Post Translation: New plugin for translating post/page content via GlotPress#602dd32 wants to merge 15 commits intoWordPress:trunkfrom
dd32 wants to merge 15 commits intoWordPress:trunkfrom
Conversation
New plugin that translates WordPress post/page content via GlotPress. Extracts translatable strings from block content, imports them into GlotPress projects, and applies translations on the frontend. - Block parser system with specialized parsers for core blocks (paragraph, heading, image, list, quote, button, shortcode) and a BasicText fallback for unknown blocks - Editor sidebar panel with toggle to enable translation per-post - Admin hook schedules GlotPress import on post save - Frontend filters (the_content, the_title, render_block) apply translations with transient caching using compound invalidation key - Adds $found parameter to GlotPress Translate Bridge for distinguishing untranslated strings from identity translations - PHPUnit test suite (29 tests) with wp-env environment - gettext filter hooks for future live translator UI integration Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add GlotPress plugin to the wp-env environment with lifecycle scripts that set up permalinks and install GlotPress DB tables - Fix wp-env plugin paths (relative to environments/ working dir) - Update bootstrap to load GlotPress with case-insensitive path lookup and install its schema for the test database - Add 6 end-to-end tests covering the full translation pipeline: import strings into GlotPress, add translations, verify frontend serves translated content, verify multi-post string preservation, verify auto-creation of projects with translation sets Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The wp-env container ships PHPUnit 10.5 which is incompatible with the bundled WordPress test suite (uses removed parseTestMethodAnnotations). Add a conditional step to downgrade to PHPUnit 9 and use the vendored binary instead of the system one. Only applies to entries that set phpunit-bin in the matrix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
- Fix all PHPCS errors across plugin files (multi-line function calls, Yoda conditions, alignment, trait/class-per-file ignores for DOMDocument properties and related types) - Add PHPDoc for $found parameter on GlotPress Translate Bridge translate() and translate_plural() methods - Fix wp-env lifecycle script to use wp-env run cli (runs in container, not on host) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use after-start.sh script for wp-env lifecycle (matching plugin-directory pattern) instead of inline wp-env commands that fail during the start process - Exclude */build/* from PHPCS - wp-scripts generated asset files are not hand-written PHP Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add missing parameter types to PHPDoc and visibility declarations to translate() and translate_plural() methods. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…nment. - Map mocks/mu-plugins for the dev login button on the login screen - Add wporg-main theme and wporg-parent-2021 parent theme - Activate wporg-main in after-start script Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
switch_to_blog() and restore_current_blog() do not exist on single-site WordPress installs. Guard all calls with is_multisite() checks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ctory. The mocks/mu-plugins directory includes a loader that requires wporg-mu-plugins which is not available in this environment. Map just the dev-login file instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Installs Spanish language pack and switches the site language so the frontend always attempts to translate post content. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
In cron context, get_permalink() resolves to the wrong URL because the site URL is not available from the request. Pass the permalink as a cron argument so it uses the correct URL from save time. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Rename GlotPress project hierarchy from disabled/posttranslation to post-content (top-level "Post Content" project with site name as child project) - Importer auto-creates parent project if it does not exist - Child projects use the site name from get_bloginfo() instead of slug - After-start script creates parent project with Spanish translation set, sample page with various block types and translation enabled, and triggers cron to import strings into GlotPress - Update tests for new project path Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
`wp post-translation import` finds all published posts with translation enabled and imports their strings into GlotPress. Operates per-site (use --url= on multisite). Supports --post_id, --post_type, and --dry-run flags. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6 tasks
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
wporg-post-translationplugin that translates WordPress post/page content through GlotPressthe_content,the_title,render_block) apply translations with transient caching using a compound invalidation key (posts + GlotPress last_changed)$foundparameter to GlotPress Translate Bridge for distinguishing untranslated stringsgettextfilter hooks for future live translator UI integration (informed by theadd/translatorbranch)environments/post-translation/Context
Currently, translatable page content on WordPress.org lives in theme template files (wporg-main-2022) so it can be wrapped in translation functions. This means content changes require theme code changes rather than using the WordPress editor. This plugin enables page content to live in the database as normal posts/pages while still being translatable through GlotPress.
Informed by prior work on the
feature/post-translationandadd/translatorbranches, but is a fresh implementation.Test plan
cd environments && npm run post-translation:env startnpm run post-translation:env -- run cli --env-cwd=wp-content/plugins/wporg-post-translation phpunit🤖 Generated with Claude Code