From ae743856b23ccd1a6e02cde789d2aba8e734070f Mon Sep 17 00:00:00 2001 From: "tg(x)" <*@tg-x.net> Date: Tue, 1 Mar 2016 15:17:19 +0100 Subject: walle-wx-i18n --- dev-wallet-wx.rst | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'dev-wallet-wx.rst') diff --git a/dev-wallet-wx.rst b/dev-wallet-wx.rst index a458ebae..5f21ace9 100644 --- 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. -- cgit v1.2.3 From 0c09f817c1eeadc2640782b422c00a1e7c4438a3 Mon Sep 17 00:00:00 2001 From: "tg(x)" <*@tg-x.net> Date: Tue, 1 Mar 2016 15:23:36 +0100 Subject: walle-wx-i18n --- dev-wallet-wx.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'dev-wallet-wx.rst') diff --git a/dev-wallet-wx.rst b/dev-wallet-wx.rst index 5f21ace9..255a8736 100644 --- a/dev-wallet-wx.rst +++ b/dev-wallet-wx.rst @@ -157,18 +157,21 @@ Strings in the JavaScript code are internationalised using the following functio - *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.`); + + 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. @@ -176,6 +179,7 @@ Include ``lib/vendor/jed.js``, ``lib/i18n.js``, ``lib/i18n-strings.js`` to use t 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. -- cgit v1.2.3 From 993ada836fc6992997cc69c1672ceb8d2dcf08c2 Mon Sep 17 00:00:00 2001 From: "tg(x)" <*@tg-x.net> Date: Tue, 1 Mar 2016 15:27:56 +0100 Subject: wallet-wx-i18n --- dev-wallet-wx.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'dev-wallet-wx.rst') diff --git a/dev-wallet-wx.rst b/dev-wallet-wx.rst index 255a8736..898b754c 100644 --- a/dev-wallet-wx.rst +++ b/dev-wallet-wx.rst @@ -158,12 +158,12 @@ Strings in the JavaScript code are internationalised using the following functio - *i18n*: translate string with arbitrary arguments, the result is returned as string. .. code-block:: js - ``i18n`You have ${n} coins.`` + 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.parts`Visit ${link} to get more coins.` - *i18n.pluralize*: translate with plural form @@ -182,5 +182,11 @@ To extract strings from sources and update the .po files, run: $ make i18n -In static HTML files the ``lang`` attribute is used for language-specific strings. +In static HTML files the ``lang`` attribute is used for language-specific strings: + +.. code-block:: html + +

Hello World!

+

Hallo Welt!

+ ``lib/i18n.js`` and ``style/lang.css`` needs to be included for this to work. -- cgit v1.2.3 From 699c27607522195cff8af2892bde75673ae8811e Mon Sep 17 00:00:00 2001 From: "tg(x)" <*@tg-x.net> Date: Tue, 1 Mar 2016 15:30:03 +0100 Subject: wallet-wx-i18n --- dev-wallet-wx.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'dev-wallet-wx.rst') diff --git a/dev-wallet-wx.rst b/dev-wallet-wx.rst index 898b754c..4516c015 100644 --- a/dev-wallet-wx.rst +++ b/dev-wallet-wx.rst @@ -153,12 +153,12 @@ call `mocha` with the right parameters. Internationalisation -------------------- -Strings in the JavaScript code are internationalised using the following functions, +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`You have ${n} coins.` - *i18n.parts*: Interpolate i18nized values with arbitrary objects. Useful for example to include HTML elements. .. code-block:: js -- cgit v1.2.3 From c091da731ecf747f93a28f232ffc6c8c11495f8f Mon Sep 17 00:00:00 2001 From: "tg(x)" <*@tg-x.net> Date: Tue, 1 Mar 2016 15:39:16 +0100 Subject: wallet-wx-i18n --- dev-wallet-wx.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'dev-wallet-wx.rst') diff --git a/dev-wallet-wx.rst b/dev-wallet-wx.rst index 4516c015..d3738631 100644 --- a/dev-wallet-wx.rst +++ b/dev-wallet-wx.rst @@ -160,12 +160,16 @@ Strings in the JavaScript code are internationalised using the following functio i18n`You have ${n} coins.` -- *i18n.parts*: Interpolate i18nized values with arbitrary objects. Useful for example to include HTML elements. +- *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 +- *i18n.pluralize*: translate with plural form. + The i18n.number() function returns a ``PluralNumber`` object + that specifies the argument that determines the plural form, + if not present the first numeric argument is used. .. code-block:: js -- cgit v1.2.3