[wp-trac] [WordPress Trac] #50999: Scripts loaded through concatenation don't print their translations.

WordPress Trac noreply at wordpress.org
Wed Aug 26 20:03:10 UTC 2020


#50999: Scripts loaded through concatenation don't print their translations.
--------------------------+----------------------------------------
 Reporter:  herregroen    |       Owner:  SergeyBiryukov
     Type:  defect (bug)  |      Status:  reviewing
 Priority:  high          |   Milestone:  5.5.1
Component:  I18N          |     Version:  5.5
 Severity:  major         |  Resolution:
 Keywords:  has-patch     |     Focuses:  accessibility, javascript
--------------------------+----------------------------------------

Comment (by desrosj):

 I'm still trying to determine exactly what caused this regression. The
 code being changed in [attachment:"translations-no-concat.patch"] has been
 pretty much untouched since it was merged into core in 5.0, so a change
 elsewhere is most likely the culprit.

 I am currently trying to confirm a suspicion that I have that the changes
 associated with #20491 made in 5.5 are the reason this is happening.

 When a script is localized to a handle that is concatenated, the localized
 script is printed to the page through `$print_code` in the `WP_Scripts`
 class. Because they are printed out in the page source, the script can
 still be loaded through `load-scripts.php`.

 Switching the JavaScript strings to use `wp.i18n` would cause these
 translations to no longer be printed to the page through
 `WP_Scripts->print_extra_scripts()` because the new method of JS string
 localization manually prints out the translations after the script is
 concatenated.

 If this thinking is correct, the patch I am attaching ''should'' allow
 scripts with JS translations to continue to be concatenated without the
 issue. Some testing/sanity checking would be much appreciated.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50999#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list