[wp-trac] [WordPress Trac] #45425: Add a filter to the translation file location for script localisation

WordPress Trac noreply at wordpress.org
Sun Dec 9 18:09:53 UTC 2018


#45425: Add a filter to the translation file location for script localisation
--------------------------+-------------------------
 Reporter:  johnbillion   |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  5.0.1
Component:  I18N          |     Version:  5.0
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  javascript
--------------------------+-------------------------

Comment (by dimadin):

 I am not sure should this be in this separate ticket or handled here.
 Before JavaScript translations and WP 5.0 (since [3425] and WP 2.0.1),
 every string was passed through some of
 [https://developer.wordpress.org/?s=gettext&post_type%5B%5D=wp-parser-hook
 gettext filters]. This enabled manipulations of translations but also of
 originals in English (e.g. change some text). There are
 [https://www.wpdirectory.net/search/01CY9ZR40QMVWCHJ33XH92J8F5 over 500
 plugins] in WP.org repository that use them. They are also
 [https://i18n.trac.wordpress.org/browser/sr_RS/trunk/dist/wp-
 content/plugins/srlatin.php?rev=45101#L105 used] by Serbian localization
 to ship both Serbian Cyrillic and Serbian Latin version in one package.

 We don't have anything like this with JavaScript translations. They aren't
 filterable at all (this is the reason there is no WP 5.0 in Serbian
 Latin). One [https://github.com/WordPress/gutenberg/issues/12407 option]
 is to filter strings on JavaScript side. But plugins that already use
 those filters will not work there, they need to port their filters to
 JavaScript version (and some implementations can't be ported at all) and
 have both PHP and JavaScript versions.

 Since we already load JavaScript translations in PHP, can we loop through
 those translations and then apply `gettext` filters? One problem I see
 already is that for plural strings since we can't use
 [https://developer.wordpress.org/reference/hooks/ngettext/ ngettext
 filter].

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


More information about the wp-trac mailing list