[wp-trac] [WordPress Trac] #60891: When plugins have a custom directory, script translations don’t load correctly

WordPress Trac noreply at wordpress.org
Wed Apr 3 00:36:41 UTC 2024


#60891: When plugins have a custom directory, script translations don’t load
correctly
--------------------------+-----------------------------
 Reporter:  coreymckrill  |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  I18N          |    Version:  6.4.3
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 This issue was originally reported as a problem
 [https://github.com/woocommerce/woocommerce/issues/44781 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:

 1. On a fresh WordPress installation, define the `WP_PLUGIN_DIR` and
 `WP_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' );
 }}}

 2. 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.
 1. Install and activate the Query Monitor plugin to make it easier to see
 which translation files get loaded on a given request.
 1. 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 into
 `wp-content/languages/plugins`.
 1. 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.
 1. 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`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60891>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list