Преглед на файлове

Update i18n documentation. Remove unused dependency `po2json`

JC Brand преди 1 седмица
родител
ревизия
6d76475910
променени са 5 файла, в които са добавени 20 реда и са изтрити 74 реда
  1. 0 1
      demo/embedded.html
  2. 12 70
      docs/source/translations.rst
  3. 1 1
      index.html
  4. 7 1
      package-lock.json
  5. 0 1
      package.json

+ 0 - 1
demo/embedded.html

@@ -85,7 +85,6 @@
             'anonymous@conference.nomnom.im',
         ],
         singleton: true,
-        locales_url: "../locale/{{{locale}}}/LC_MESSAGES/converse.json",
         view_mode: 'embedded',
     });
 </script>

+ 12 - 70
docs/source/translations.rst

@@ -7,13 +7,12 @@ Translations
 ============
 
 Converse supports localization of its user interface and date formats. As
-of writing, 17 languages are supported.
+of writing, 46 languages are supported.
 
-The translations of Converse can be found in the `locale
-<https://github.com/jcbrand/converse.js/tree/master/locale>`_ directory.
+The translations of Converse can be found in the `src/i18n <https://github.com/conversejs/converse.js/tree/master/src/i18n/>`_ directory.
 
 Translations of Converse are very welcome. You can add translations either
-manually by editing the ``.po`` files in the above-mentioned ``locale``
+manually by editing the ``.po`` files in the ``src/i18n/locales``
 directory, or through the web at `weblate <https://hosted.weblate.org/projects/conversejs/#languages>`_.
 
 As of version 3.3.0, Converse no longer automatically bundles translations
@@ -38,22 +37,23 @@ manually in a checkout of the Converse source repository.
 
 These tasks are documented below.
 
-Updating the translations template (.pot file)
-----------------------------------------------
+Updating the global translations template (.pot file)
+-----------------------------------------------------
 
 The gettext `.pot` file located in
-`./locale/converse.pot <https://github.com/jcbrand/converse.js/blob/master/locale/converse.pot>`_
+`./locale/converse.pot <https://github.com/conversejs/converse.js/blob/master/src/i18n/converse.pot>`_
 is the template containing all translations and from which for each language an individual PO
 file is generated.
 
 The `.pot` file contains all translateable strings extracted from Converse.
 
-To make a user-facing string translateable, wrap it in the double underscore helper
+To make a user-facing string is translateable, wrap it in the double underscore helper
 function like so:
 
 .. code-block:: javascript
 
-    __('This string will be translated at runtime');
+    const { __ } = _converse.i18n.env;
+    const str = __('This string will be translated at runtime');
 
 After adding the string, you'll need to regenerate the POT file:
 
@@ -71,8 +71,8 @@ translated into, do the following
 
 ::
 
-    mkdir -p ./locale/pl/LC_MESSAGES
-    msginit -i ./locale/converse.pot -o ./locale/pl/LC_MESSAGES/converse.po -l pl
+    mkdir -p ./src/i18n/locales/pl/LC_MESSAGES
+    msginit -i ./src/i18n/converse.pot -o ./src/i18n/locales/pl/LC_MESSAGES/converse.po -l pl
 
 Please make sure to add the following attributes at the top of the file (under
 *Content-Transfer-Encoding*). They are required as configuration settings for Jed,
@@ -94,7 +94,7 @@ You can update the `.po` file for a specific language by doing the following:
 
 ::
 
-    msgmerge ./locale/de/LC_MESSAGES/converse.po ./locale/converse.pot -U
+    msgmerge ./src/i18n/locales/de/LC_MESSAGES/converse.po ./src/i18n/converse.pot -U
 
 To do this for ALL languages, run:
 
@@ -104,61 +104,3 @@ To do this for ALL languages, run:
 
 The resulting `.po` file is then what gets translated.
 
-Generating a JSON file from a translations file
------------------------------------------------
-
-Unfortunately `Jed <http://slexaxton.github.io/Jed>`_, which we use for
-translations in Converse cannot use the `.po` files directly. We have
-to generate from it a file in JSON format and then put that in a `.js` file
-for the specific language.
-
-To generate JSON from a PO file, you'll need po2json for node.js. Run the
-following command to install it (npm being the node.js package manager):
-
-::
-
-    npm install po2json
-
-You can then convert the translations into JSON format:
-
-::
-
-    po2json -p -f jed -d converse locale/de/LC_MESSAGES/converse.po locale/de/LC_MESSAGES/converse.json
-
-To do this for ALL languages, run:
-
-::
-
-    make po2json
-
-
-.. note::
-    If you are adding translations for a new language that is not already supported,
-    you'll have to add the language path in main.js and make one more edit in ./src/locales.js
-    to make sure the language is loaded by require.js.
-
-
-Making sure the JSON file will get loaded
-------------------------------------------
-
-Finally, make sure that the language code is added to the list of default
-values for the ``locales`` config setting.
-
-This is done in ``src/converse-core.js``.
-
-Look for the following section:
-
-.. code-block:: javascript
-
-        // Default configuration values
-        // ----------------------------
-        this.default_settings = {
-            // ... Omitted for brevity
-            locales_url: 'locale/{{{locale}}}/LC_MESSAGES/converse.json',
-            locales: [
-                'af', 'ar', 'bg', 'ca', 'de', 'es', 'en', 'fr', 'he',
-                'hu', 'id', 'it', 'ja', 'nb', 'nl',
-                'pl', 'pt_BR', 'ru', 'tr', 'uk', 'zh_CN', 'zh_TW'
-            ],
-            // ... Omitted for brevity
-        };

+ 1 - 1
index.html

@@ -182,7 +182,7 @@
                             <li>Message Styling (<a href="https://xmpp.org/extensions/xep-0384.html" target="_blank" rel="noopener">XEP 393</a>)</li>
                             <li>Anonymous logins, see the <a href="/demo/anonymous.html" target="_blank" rel="noopener">anonymous login demo</a></li>
                             <li>Message corrections, retractions and moderation</li>
-                            <li>Translated into over 40 languages</li>
+                            <li>Translated into over 45 languages</li>
                         </ul>
                     </div>
                 </div>

+ 7 - 1
package-lock.json

@@ -60,7 +60,6 @@
         "minify-html-literals-loader": "^1.1.1",
         "minimist": "^1.2.6",
         "po-loader": "0.7.0",
-        "po2json": "^1.0.0-beta-3",
         "postcss": "^8.4.16",
         "postcss-loader": "^8.1.1",
         "sass": "^1.86.2",
@@ -3207,6 +3206,7 @@
       "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==",
       "dev": true,
       "license": "MIT",
+      "peer": true,
       "dependencies": {
         "iconv-lite": "^0.6.2"
       }
@@ -3217,6 +3217,7 @@
       "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
       "dev": true,
       "license": "MIT",
+      "peer": true,
       "dependencies": {
         "safer-buffer": ">= 2.1.2 < 3.0.0"
       },
@@ -4173,6 +4174,7 @@
       "integrity": "sha512-FDs/7XjNw58ToQwJFO7avZZbPecSYgw8PBYhd0An+4JtZSrSzKhEvTsVV2uqdO7VziWTOGSgLGD5YRPdsCjF7Q==",
       "dev": true,
       "license": "MIT",
+      "peer": true,
       "dependencies": {
         "encoding": "^0.1.12",
         "safe-buffer": "^5.1.2"
@@ -4184,6 +4186,7 @@
       "integrity": "sha512-UyqIL3Ul4NryU95Wome/qtlcuVIqgEWVIFw0zi7Lv14ACLXfaVDCbrjZ7o+3BZ7u+4NS1mP/2O1eXZoHCoas8g==",
       "dev": true,
       "license": "MIT",
+      "peer": true,
       "dependencies": {
         "gettext-parser": "^1.4.0"
       },
@@ -4197,6 +4200,7 @@
       "integrity": "sha512-sedZYLHlHeBop/gZ1jdg59hlUEcpcZJofLq2JFwJT1zTqAU3l2wFv6IsuwFHGqbiT9DWzMUW4/em2+hspnmMMA==",
       "dev": true,
       "license": "MIT",
+      "peer": true,
       "dependencies": {
         "encoding": "^0.1.12",
         "safe-buffer": "^5.1.1"
@@ -6178,6 +6182,7 @@
       "integrity": "sha512-taS8y6ZEGzPAs0rygW9CuUPY8C3Zgx6cBy31QXxG2JlWS3fLxj/kuD3cbIfXBg30PuYN7J5oyBa/TIRjyqFFtg==",
       "dev": true,
       "license": "LGPL-2.0-or-later",
+      "peer": true,
       "dependencies": {
         "commander": "^6.0.0",
         "gettext-parser": "2.0.0",
@@ -6201,6 +6206,7 @@
       "integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==",
       "dev": true,
       "license": "MIT",
+      "peer": true,
       "engines": {
         "node": ">= 6"
       }

+ 0 - 1
package.json

@@ -116,7 +116,6 @@
     "minify-html-literals-loader": "^1.1.1",
     "minimist": "^1.2.6",
     "po-loader": "0.7.0",
-    "po2json": "^1.0.0-beta-3",
     "postcss": "^8.4.16",
     "postcss-loader": "^8.1.1",
     "sass": "^1.86.2",