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

WordPress Trac noreply at wordpress.org
Fri Sep 23 15:05:00 UTC 2016


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

Comment (by swissspidy):

 In [attachment:20491.6.diff]:

 * Introduce `wp.i18n.loadLocaleData()` and `wp.i18n.getLocale()`.
 * Introduce `get_js_i18n_data()` to load a JSON translation file.
 * Introduce `WP_Scripts:: load_translation_file()` to pass that JSON to
 `wp.i18n.loadLocaleData()`.
 * Add some more QUnit tests.

 If `get_js_i18n_data()` and `WP_Scripts:: load_translation_file()` seem
 legit I'll happily continue working on it.

 Regarding `sprintf()`, this patch also removes `wp.i18n.sprintf` as Jed's
 implementation is really out of date. Jed even encourages removing it from
 its source code:

 {{{
 // This is not internally used, so you can remove it if you have this
 // available somewhere else, or want to use a different system.
 }}}

 We should rather add a proper version to `wp.util`. If anyone want's to
 use `sprintf` with translations, they'd have to load both scripts.

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


More information about the wp-trac mailing list