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

WordPress Trac noreply at wordpress.org
Mon Jun 20 17:30:29 UTC 2016


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

Comment (by swissspidy):

 Finally got time to look into this in the hope to dig more into it at the
 WordCamp Europe Contributor Day.

 [attachment:20491.diff] is built upon @ocean90's patch and borrows some
 parts from #22229 as well.

 What it does:

 * JS: Introduces `wp.i18n` with some helper functions:
 `addTranslations()`, `numberFormat()`, `__()`, `_x()`, `_n()`, `_nx()`
 * PHP: Adds `_n_js()` and `_nx_js()` that use `translate_plural_for_js()`
 to return an output Jed likes. `wp_i18n_add_default_js_translations()` has
 some sample data for that.
 * Adds some JS & PHP unit tests

 Note: There is one failing test for `wp.i18n.numberFormat()` because the
 rounding is wrong and not equivalent to `number_format_i18n()`.

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


More information about the wp-trac mailing list