Skip to content

Add .l10n.php syntax validation to translation workflows#208

Open
chrisdavidmiles wants to merge 1 commit intomainfrom
PRESS0-4223-l10n-validation
Open

Add .l10n.php syntax validation to translation workflows#208
chrisdavidmiles wants to merge 1 commit intomainfrom
PRESS0-4223-l10n-validation

Conversation

@chrisdavidmiles
Copy link
Copy Markdown

Summary

  • Fixes the root cause of PRESS0-4223: wp i18n make-php (WP-CLI) generates invalid PHP when a PO file has zero translated strings — a stray comma in an empty messages array causes a fatal parse error
  • This broke WP Admin for Bluehost/HostGator customers using non-en_US locales (en_AU, en_GB, de_DE, etc.)
  • Adds two steps to both reusable-translations.yml and reusable-module-prep-release.yml:
    1. Auto-fix: strips the known stray-comma pattern from generated .l10n.php files (workaround until WP-CLI is patched upstream)
    2. Validate: runs php -l on all .l10n.php files and fails the workflow if any have syntax errors — prevents broken translation files from ever shipping again

Test plan

  • Trigger a translation workflow on a module with empty PO files (no translated strings) and verify the fix step cleans up the output
  • Trigger a prep-release workflow on a module with translations and verify validation passes
  • Intentionally introduce a syntax error in a .l10n.php file and verify the validation step catches it

Fixes PRESS0-4223

🤖 Generated with Claude Code

…kflows

wp i18n make-php generates invalid PHP when a PO file has zero translated
strings — it outputs a stray comma in an empty messages array, causing a
fatal parse error at runtime. This broke WP Admin for customers using
non-en_US locales (PRESS0-4223).

Both reusable-translations.yml and reusable-module-prep-release.yml now:
1. Auto-fix the known stray-comma pattern after i18n-ci-post / i18n runs
2. Validate all generated .l10n.php files with php -l, failing the
   workflow if any contain syntax errors

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant