[wp-trac] [WordPress Trac] #20491: Introduce some JavaScript i18n functions

WordPress Trac noreply at wordpress.org
Fri Apr 6 21:34:21 UTC 2018


#20491: Introduce some JavaScript i18n functions
--------------------------------------+-----------------------------------
 Reporter:  johnbillion               |       Owner:  swissspidy
     Type:  enhancement               |      Status:  assigned
 Priority:  normal                    |   Milestone:  5.0
Component:  I18N                      |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:  javascript, rest-api
--------------------------------------+-----------------------------------

Comment (by nerrad):

 Just making note of this pull request I've added to the gutenberg project:
 https://github.com/WordPress/gutenberg/pull/6051 (and the corresponding
 issue: https://github.com/WordPress/gutenberg/issues/6015)

 I think it provides a good path forward for handling getting the subset of
 strings needed for any js files loaded on the fly.

 I'm still uncertain how the php part of this piece will go but at a
 minimum it would require:

 1. An api for registering a json map file that provides a map of js
 "chunk" to strings in that chunk (or maybe that would be auto-detected
 from a standard "map" file name).
 2. An api for plugins to register scripts to that map (either an
 additional arg on `wp_register_script` or `wp_enqueue_script` or as I
 suggested in the issue a standalone method
 `wp_register_script_i18($script_handle, $chunk_name, $domain)`
 3. On printing enqueued scripts, `WP_Scripts` would grab the list of
 registered "i18n chunks" and using that grab the strings from
 $translations to pass to `wpi18n.setLocale` (assuming the wpi18n package
 is what lands in core).

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


More information about the wp-trac mailing list