Changes between Initial Version and Version 1 of Ticket #20491, comment 8
- Timestamp:
- 07/20/2014 03:24:22 PM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #20491, comment 8
initial v1 1 I think a good set of i18n javascript functions improves the javascript localisation, especially for plural sentences. So I have here a first "sketch" of those functions, primarily focussed on gettext for javascript. See it all at [https://github.com/TV-productions/WP-JS-GetText GitHub]. It is a small plugin that will show some translated messages from core if you activate it. 2 1 3 How it works: 2 4 * It uses the Po/Mo files that are parsed in PHP to generate a structure that the javascript functions will use. … … 9 11 Possible drawbacks: 10 12 * All the translated strings are always loaded: for the current core translations (textdomain 'default') is that about a 600KB script. 11 * There has to be a JS function like sprintf to parse `%s`, `%d`, `%1$s`, etc. Possible starting point: [ sprintf for js](https://github.com/kvz/phpjs/blob/master/functions/strings/sprintf.js)13 * There has to be a JS function like sprintf to parse `%s`, `%d`, `%1$s`, etc. Possible starting point: [https://github.com/kvz/phpjs/blob/master/functions/strings/sprintf.js sprintf for js] 12 14 * It uses the standard plural expression from gettext (for example `n!=1`), but this code is executed in js and maybe a security issue. the plural expression is currently filtered by a regular expression that removes all charters that shouldn't be in a plural expression, but it still is a bit tricky. 13 15