Make WordPress Core

Opened 8 months ago

Closed 6 months ago

Last modified 6 months ago

#62016 closed defect (bug) (fixed)

The .json files with theme translations are loaded only if they are present in the plugins path

Reported by: itapress's profile itapress Owned by: swissspidy's profile swissspidy
Milestone: 6.7 Priority: normal
Severity: normal Version: 6.6
Component: I18N Keywords: has-patch has-unit-tests needs-testing
Focuses: Cc:

Description

Hello.

Following this change: https://github.com/WordPress/WordPress/commit/54a61e9c9b36970fe18b33fe2c35a5823617ffca

Theme translation .json files are loaded only if present in the "wp-content/languages/plugins/" path and not from the “wp-content/languages/themes/” path.

I discovered the problem and tested it with the Dutch translation of the Kadence and Astra themes.

Thanks.

Attachments (4)

ticket-62016-wp-6.6.2-main-site.png (136.2 KB) - added by staurand 6 months ago.
ticket-62016-wp-6.6.2-sub-site.png (206.0 KB) - added by staurand 6 months ago.
ticket-62016-patched-main-site.png (109.1 KB) - added by staurand 6 months ago.
ticket-62016-patched-sub-site.png (185.7 KB) - added by staurand 6 months ago.

Download all attachments as: .zip

Change History (27)

#1 @swissspidy
8 months ago

  • Milestone changed from Awaiting Review to 6.7
  • Owner set to swissspidy
  • Status changed from new to reviewing
  • Version changed from 6.6.1 to 6.6

Thanks for your report! I will look into it.

This ticket was mentioned in PR #7423 on WordPress/wordpress-develop by @swissspidy.


7 months ago
#2

  • Keywords has-patch added

The change in https://core.trac.wordpress.org/ticket/60891 / https://core.trac.wordpress.org/changeset/57922 was not tested enough with themes that load script translations. It caused a regression where WP tried to look up script translations for a theme in wp-content/languages/plugins.

Even when using a custom WP_PLUGIN_DIR/WP_PLUGIN_URL configuration, we should always use the correct path for themes and plugins alike.

To-do:

  • [ ] Add unit tests

Trac ticket: https://core.trac.wordpress.org/ticket/62016

#3 @swissspidy
7 months ago

  • Keywords needs-unit-tests needs-testing added

#4 @swissspidy
7 months ago

  • Keywords has-unit-tests added; needs-unit-tests removed

@itapress Does the proposed patch fix the issue for you?

#5 @itapress
7 months ago

@swissspidy I tried this fix and everything works fine for me. Thanks!

#6 @swissspidy
7 months ago

  • Keywords commit added

#7 @swissspidy
7 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 59126:

I18N: Fix script languages path for themes.

Remove hardcoded path added in [57922] which ignored the fact that themes can also use script translations.
They should not be affected even if plugins are installed outside the typical wp-content/plugins location.

Props itapress, swissspidy.
Fixes #62016.

#9 @swissspidy
7 months ago

#62157 was marked as a duplicate.

#10 @swissspidy
7 months ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#11 @swissspidy
7 months ago

  • Keywords needs-patch added; has-patch needs-testing has-unit-tests commit removed

#12 @swissspidy
7 months ago

#62155 was marked as a duplicate.

@them.es commented on PR #7423:


7 months ago
#13

@swissspidy Could you have a look at whether this is a viable alternative approach?

Replace the changes in this commit with only the following line:
Line 1210 $languages_path = WP_LANG_DIR . '/' . $relative[0];

At least this fixes a regression reported 2 weeks ago: https://core.trac.wordpress.org/ticket/62155

@swissspidy commented on PR #7423:


7 months ago
#14

No, this just reintroduces the original bug.

This ticket was mentioned in PR #7562 on WordPress/wordpress-develop by @swissspidy.


7 months ago
#15

  • Keywords has-patch has-unit-tests added; needs-patch removed

Ensure correct languages path when using a custom WP_PLUGIN_DIR / WP_PLUGIN_URL configuration, a custom theme root, and/or using Multisite with subdirectories.

Trac ticket: https://core.trac.wordpress.org/ticket/62016

@swissspidy commented on PR #7423:


7 months ago
#16

@them-es #7562 should address this, please test

#17 @swissspidy
7 months ago

  • Keywords needs-testing added

@them.es commented on PR #7423:


7 months ago
#18

@swissspidy Yes that seems to fix the reported Multisite regression. Thank you for the quick turnaround 👍

#19 @staurand
6 months ago

Reproduction Report

Description

The issue can be reproduced in the latest stable WordPress version (6.6.2).

Environment

  • WordPress: 6.6.2
  • PHP: 8.1.8
  • Server: Apache/2.4.53 (Debian)
  • Database: mysqli (Server: 5.7.43 / Client: mysqlnd 8.1.8)
  • Browser: Firefox 131.0
  • OS: macOS
  • Theme: Twenty Twenty Four child theme
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.1.0

Actual Results

  1. ✅ Text is not translated (See "Translated?" should be "Traduit!")

Additional Notes

  • Tested with a child theme of Twenty Twenty Four loading js file that should alerts a translated text on Multisite (main site + sub site)

Supplemental Artifacts

https://core.trac.wordpress.org/attachment/ticket/62016/ticket-62016-wp-6.6.2-main-site.png
https://core.trac.wordpress.org/attachment/ticket/62016/ticket-62016-wp-6.6.2-sub-site.png

#20 @staurand
6 months ago

Test Report

Description

The issue is fixed with https://github.com/WordPress/wordpress-develop/pull/7562

Environment

  • WordPress: 6.5-beta2-57671-src
  • PHP: 8.1.8
  • Server: Apache/2.4.53 (Debian)
  • Database: mysqli (Server: 5.7.43 / Client: mysqlnd 8.1.8)
  • Browser: Firefox 131.0
  • OS: macOS
  • Theme: Twenty Twenty Four child theme
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.1.0

Actual Results

  1. ✅ The text is translated

Additional Notes

  • Tested with a child theme of Twenty Twenty Four loading js file that should alert a translated text on Multisite (main site + sub site)

Supplemental Artifacts

https://core.trac.wordpress.org/attachment/ticket/62016/ticket-62016-patched-main-site.png
https://core.trac.wordpress.org/attachment/ticket/62016/ticket-62016-patched-sub-site.png

#21 @swissspidy
6 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 59264:

I18N: Fix script languages path on Multisite.

This is a follow-up to [59126] (itself a follow-up to [57922]), which caused a regression when determining the right path when loading script translations.

Props swissspidy, themes-1, staurand.
Fixes #62016.

#23 @hupe13
6 months ago

Thank you for fixing! Works for me in 6.7-RC1.

Note: See TracTickets for help on using tickets.