diff --git a/README.md b/README.md index 7b70e8f03d..4999b239ce 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,6 @@ $ ./do watch ``` # JS Dependencies. - In order to use a JS library (let's take Handlebars as an example), you need to follow these steps: * add "handlebars" as a dependency in the `package.json` file @@ -111,3 +110,20 @@ $ cd assets/js/lib/ $ ln -nsf ../../../node_modules/handlebars/dist/handlebars.min.js handlebars.min.js ``` * make sure to push the symlink onto the repository + +# Translations. +When editing a Twig template (`views/*.html`), you have to the following WordPress functions: + +* `__`: returns a string +* `_n`: returns a pluralized string + +```html +

{{ __('Click %shere%s!') | format('', '') | raw }}

+``` +This will print: "Click [here](#)" + +```html +

{{ _n('deleted one message', 'deleted %d messages', count, 'wysija-newsletters') | format(count) }}

+``` +This will print "deleted one message" (if count === 1) +This will print "deleted X message" (if count !== 1) \ No newline at end of file diff --git a/lib/renderer/i18n.php b/lib/renderer/i18n.php index 6c7e5aa148..612937ca56 100644 --- a/lib/renderer/i18n.php +++ b/lib/renderer/i18n.php @@ -14,7 +14,7 @@ class i18n extends \Twig_Extension { // twig custom functions $twig_functions = array(); // list of WP functions to map - $functions = array('_', '__', '_e', '_c', '_n', '_x'); + $functions = array('__', '_n'); foreach($functions as $function) { $twig_functions[] = new \Twig_SimpleFunction(