[wp-trac] [WordPress Trac] #45103: Automatically load JavaScript translations when scripts are enqueued if these exist.

WordPress Trac noreply at wordpress.org
Wed Oct 24 12:21:52 UTC 2018


#45103: Automatically load JavaScript translations when scripts are enqueued if
these exist.
-------------------------+-------------------------
 Reporter:  herregroen   |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  high         |   Milestone:  5.0
Component:  I18N         |     Version:  trunk
 Severity:  critical     |  Resolution:
 Keywords:  needs-patch  |     Focuses:  javascript
-------------------------+-------------------------

Comment (by nerrad):

 Apologies for delay in getting back to you, I'm in a bit of a time crunch
 working on GB related tasks for my own projects :)

 Work looks good. After thinking more about it though, I'm a bit concerned
 about the requirement to set translations after enqueuing scripts.
 Primary reason is it diverges a bit from the established pattern for
 working with the wp_scripts api that exists and developers are used to.
 Namely,  `wp_localize_script` and `wp_add_inline_script` all currently
 encourage adding information immediately subsequent to registering a
 script.

 I know in the projects I  currently work on, we tend to register scripts,
 their handles and meta data early in requests and then enqueues are
 handled separately.

 I'd like to see us move back towards just registering locale details with
 `WP_Scripts::set_translations` so translations can be registered after
 registering a script.

 I realize there is a bit of a time crunch though, so this could be landed
 and iterated on as is.  I'm just not keen on this being the final
 approach.

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


More information about the wp-trac mailing list