Skip to content

i18n: Fix loading of theme translation files#48016

Merged
dlind1 merged 3 commits intotrunkfrom
fix/theme-translation-files-loading
Apr 9, 2026
Merged

i18n: Fix loading of theme translation files#48016
dlind1 merged 3 commits intotrunkfrom
fix/theme-translation-files-loading

Conversation

@dlind1
Copy link
Copy Markdown
Contributor

@dlind1 dlind1 commented Apr 8, 2026

Fixes I18N-338

Proposed changes

  • Update the logic for rewriting MO file paths from something like 'theme-fr_FR.mo' to 'fr.mo'.
  • The issue is caused by the fact that on WPCloud sites the WordPress.com themes are symlinked, so _load_textdomain_just_in_time operates as if the translation files are not located in the theme languages folder and uses the "{$path}{$domain}-{$locale}.mo" format instead of "{$path}{$locale}.mo".

Does this pull request change what data or activity we track or use?

No.

Testing instructions

  • To reproduce create a new WPCloud site; install the Rowling theme; change the site language to a popular non-English locale like Spanish, German, French or Japanese; publish a few test posts; then open a post and confirm that the Previous/Next labels appear untranslated.
  • Apply the PR and confirm that the issue is resolved.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (WordPress.com Site Helper), and enable the fix/theme-translation-files-loading branch.

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Wpcomsh plugin:

  • Next scheduled release: Atomic deploys happen twice daily on weekdays (p9o2xV-2EN-p2)

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Apr 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts WPComSH’s MO-file fallback logic so theme translations continue to load correctly on WPCloud, where symlinked theme directories can cause WordPress to compute theme MO filenames using {textdomain}-{locale}.mo instead of {locale}.mo.

Changes:

  • Extends the load_textdomain_mofile filter callback to accept the text domain and detect {textdomain}-{locale} theme MO basenames.
  • Strips the theme textdomain prefix from the computed MO basename (when applicable) before mapping WP.org locales to WP.com slugs.
  • Adds a wpcomsh changelog fragment documenting the fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
projects/plugins/wpcomsh/i18n.php Updates MO fallback rewriting to handle theme MO basenames prefixed with the textdomain under theme directories.
projects/plugins/wpcomsh/changelog/fix-theme-translation-files-loading Adds a patch-level changelog entry describing the translation loading fix.

@jp-launch-control
Copy link
Copy Markdown

jp-launch-control bot commented Apr 8, 2026

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/wpcomsh/i18n.php 33/75 (44.00%) 40.97% -22 💚

Full summary · PHP report

@dlind1 dlind1 marked this pull request as ready for review April 8, 2026 23:43
@dlind1 dlind1 merged commit 0d1a4f6 into trunk Apr 9, 2026
67 checks passed
@dlind1 dlind1 deleted the fix/theme-translation-files-loading branch April 9, 2026 18:55
@github-actions github-actions bot removed [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants