reduced mapped i18n functions to a strict minimum and updated README

This commit is contained in:
Jonathan Labreuille
2015-07-29 19:30:37 +02:00
parent f727a73297
commit f9a2d0026c
2 changed files with 18 additions and 2 deletions

View File

@@ -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
<p>{{ __('Click %shere%s!') | format('<a href="#">', '</a>') | raw }}</p>
```
This will print: "Click [here](#)"
```html
<p>{{ _n('deleted one message', 'deleted %d messages', count, 'wysija-newsletters') | format(count) }}</p>
```
This will print "deleted one message" (if count === 1)
This will print "deleted X message" (if count !== 1)

View File

@@ -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(