[wp-trac] [WordPress Trac] #20491: Introduce some JavaScript i18n functions
WordPress Trac
noreply at wordpress.org
Fri Sep 9 18:32:47 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
--------------------------------------+-----------------------------
Changes (by swissspidy):
* keywords: has-patch => has-patch has-unit-tests
Comment:
In [attachment:20491.3.diff]:
* Add `wp.i18n.esc_attr__()` using `_.escape()` including tests
* Fix `wp.i18n.numberFormat()` implementation
* Fix inline docs to declare optional params according to JSDoc standards
In [attachment:20491-applied.diff]:
* Leverage `wp.i18n` almost anywhere except for some customizer parts.
This will be helpful for testing the string extraction. I had a quick chat
with @ocean90 today and he generously volunteered to extend `makepot.php`
to make this work.
JS strings will be added to the resulting POT files as usual. After that,
JS strings need to be exported as JSON files. GlotPress already supports
exporting strings based on the source (using the `filters`GET param for
example), and I have a [https://github.com/swissspidy/glotpress-json
GlotPress plugin] in the works for the JSON export. I'll further test this
plugin and will work on adding it to GlotPress core once it's ready.
Some remaining tasks / questions:
* In PHP there's a `gettext` filter for people to override translations.
Do we need a way for developers to filter translations in JS?
* Add `wp.i18n.esc_attr_x` and probably `esc_html_*` equivalents as well.
* Figure out the best way for devs to load the JSON files when enqueuing
scripts and adjust `wp.i18n. addTranslations()` accordingly
* Make sure `wp-i18n.js` and `jed.js` get properly minified when building
I think I can handle (most of) these core parts while @ocean90 works on
`makepot.php`. Of course any help is appreciated.
Anything I'm missing?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/20491#comment:32>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list