[wp-trac] [WordPress Trac] #50999: Scripts loaded through concatenation don't print their translations.
WordPress Trac
noreply at wordpress.org
Thu Aug 27 15:42:01 UTC 2020
#50999: Scripts loaded through concatenation don't print their translations.
-------------------------------------+-------------------------------------
Reporter: herregroen | Owner: ocean90
Type: defect (bug) | Status: reviewing
Priority: high | Milestone: 5.5.1
Component: I18N | Version: 5.0
Severity: major | Resolution:
Keywords: has-patch needs-testing | Focuses: accessibility,
needs-unit-tests commit | javascript
-------------------------------------+-------------------------------------
Changes (by ocean90):
* keywords: has-patch needs-testing needs-unit-tests => has-patch needs-
testing needs-unit-tests commit
* version: 5.5 => 5.0
Comment:
Replying to [comment:25 ocean90]:
> [attachment:"50999.diff"] doesn't work for me, it seems to print raw JS
on the page due to missing `<script>` tags. [attachment:"translations-no-
concat.patch"] looks better.
>
For [attachment:"50999.diff"] you have to keep the part where
`$translations` gets wrapped with the `<script>` tags at the current
position because `$print_code` gets printed by `_print_scripts()` which
already adds the `<script>` tags. But this still doesn't work as expected
because the translation script requires `wp.i18n` to be defined which is
not the case.
tldr; [attachment:"translations-no-concat.patch"] should be the way to go
here. It's also kind of covered by the
`Tests_Dependencies_Scripts::test_wp_add_inline_script_before_after_concat_with_core_dependency()`
test.
We might want to explore in a separate ticket to re-enable concatenation
after a script has been printed which previously prevented concatenation.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50999#comment:27>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list