#60891 closed defect (bug) (fixed)
When plugins have a custom directory, script translations don’t load correctly
Reported by: | coreymckrill | Owned by: | swissspidy |
---|---|---|---|
Milestone: | 6.6 | Priority: | normal |
Severity: | normal | Version: | 5.0 |
Component: | I18N | Keywords: | has-patch has-unit-tests needs-testing has-testing-info |
Focuses: | Cc: |
Description
This issue was originally reported as a problem with WooCommerce, but it actually appears to be happening in WordPress core itself. If the plugin directory is customized using the WP_PLUGIN_DIR
constant (along with WP_PLUGIN_URL
), the language packs for plugins still get installed at wp-content/languages/plugins
. However, the paths of script translation files are calculated using the custom path instead, and the translations don't load.
To reproduce:
- On a fresh WordPress installation, define the
WP_PLUGIN_DIR
andWP_PLUGIN_URL
constants in your wp-config.php file to set a custom directory. Example:
define( 'WP_PLUGIN_DIR', ABSPATH . '/wp-content/mods' ); define( 'WP_PLUGIN_URL', 'https://localhost/wp-content/mods' );
- Install and activate a plugin on your site that has script translations. WooCommerce is a good option, but I also confirmed this with Gutenberg, and it should work with any plugin that has script translations. Confirm that the plugin successfully installed into the custom plugin directory.
- Install and activate the Query Monitor plugin to make it easier to see which translation files get loaded on a given request.
- Switch your site to a locale other than
en_US
, and then go to Dashboard > Updates to download the language pack for the installed plugins. Confirm that the language pack files successfully install intowp-content/languages/plugins
. - Find a WP Admin screen where the plugin's script translation files would be loaded. It's easier if it's a screen that has the admin bar at the top so you can easily access the Query Monitor console.
- Open the QM console on that screen, and find the Languages tab. Scroll down the list until you find entries for the text domain of the plugin you installed. Look for the "jed" type, as these are the script translations. Then note that for each script translation file, it makes a few different attempts to load. But instead of trying
wp-content/languages/plugins
, it tries (in the case of the example directory name used above),wp-content/languages/mods
.
Change History (10)
#1
@
7 months ago
- Keywords has-patch has-unit-tests added
- Milestone changed from Awaiting Review to 6.6
- Version changed from 6.4.3 to 5.0
This ticket was mentioned in PR #6346 on WordPress/wordpress-develop by @swissspidy.
7 months ago
#2
Script translations are always in wp-content/languages/plugins
, where plugins
doesn't change even when wp-content/plugins
is relocated.
Trac ticket: https://core.trac.wordpress.org/ticket/60891
#3
@
7 months ago
- Keywords needs-testing has-testing-info added
The patch looks good to me and seems to be working on my side after relocating WP_PLUGIN_DIR
.
Assuming that it can be tested more widely and in time for the next minor (see testing instruction provided in the ticket description), should we try to move it to 6.5.1?
#8
@
7 months ago
Uh?! Apologies I wrongly assumed it was introduced by Performant Translation merge 🙃
#9
@
7 months ago
- Owner set to swissspidy
- Resolution set to fixed
- Status changed from new to closed
In 57922:
Can confirm.