taler-docs

Documentation for GNU Taler components, APIs and protocols
Log | Files | Refs | README | LICENSE

commit ae743856b23ccd1a6e02cde789d2aba8e734070f
parent d1016d521da025f59e60a05c73621b4e4829f583
Author: tg(x) <*@tg-x.net>
Date:   Tue,  1 Mar 2016 15:17:19 +0100

walle-wx-i18n

Diffstat:
Mdev-wallet-wx.rst | 34+++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/dev-wallet-wx.rst b/dev-wallet-wx.rst @@ -34,7 +34,7 @@ Project Structure ----------------- .. parsed-literal:: - + **manifest.json** extension configuration **package.json** node.js package configuration **tsconfig.json** TypeScript compiler configuration @@ -148,3 +148,35 @@ library. Run the default test suite with ``npm run test``, which will call `mocha` with the right parameters. + +-------------------- +Internationalisation +-------------------- + +Strings in the JavaScript code are internationalised using the following functions, + +- *i18n*: translate string with arbitrary arguments, the result is returned as string. +.. code-block:: js + ``i18n`You have ${n} coins.`` + +- *i18n.parts*: Interpolate i18nized values with arbitrary objects. Useful for example to include HTML elements. +.. code-block:: js + ``i18n.parts`Visit ${link} to get more coins.``` + +- *i18n.pluralize*: translate with plural form + +.. code-block:: js +i18n.pluralize( + i18n`${i}: you have ${i18n.number(n)} coin.`, + `${i}: you have ${i18n.number(n)} coins.`); + +These functions are defined in ``lib/i18n.ts``. +Include ``lib/vendor/jed.js``, ``lib/i18n.js``, ``lib/i18n-strings.js`` to use them. + +To extract strings from sources and update the .po files, run: + +.. code-block:: sh + $ make i18n + +In static HTML files the ``lang`` attribute is used for language-specific strings. +``lib/i18n.js`` and ``style/lang.css`` needs to be included for this to work.