Browse Source

Backport PR #12635: Add more explanation for internationalization (translation python package) (#12648)

Co-authored-by: ChangHwan Lee / 이창환 <lch@team-mono.com>
MeeseeksMachine 2 years ago
parent
commit
f0a6c4f6a7
1 changed files with 31 additions and 1 deletions
  1. 31 1
      docs/source/extension/internationalization.rst

+ 31 - 1
docs/source/extension/internationalization.rst

@@ -47,8 +47,38 @@ You could also look at the following pull requests on the
 4. Create and publish the translation for your extension.
 
 There are two options: you can either add your extension to the JupyterLab `language packs <https://github.com/jupyterlab/language-packs/#adding-a-new-extension>`_
-or you can create a python package to distribute your extension translation (see `test example <https://github.com/jupyterlab/jupyterlab_server/tree/main/tests/translations/jupyterlab-some-package>`_).
+or you can create a python package to distribute your extension translation (see below).
 
+Create translation python package
+---------------------------------
+
+Jupyter Lab follows Gettext's approach for translation. Gettext extracts strings from source code, and compiles them with provided translation. This `article <https://www.labri.fr/perso/fleury/posts/programming/a-quick-gettext-tutorial.html>`_ briefly explains how Gettext works.
+
+By using `jupyterlab-translate <https://github.com/jupyterlab/jupyterlab-translate>`_, you can extract, update, and compile your translation.
+
+After that, you must include your compiled translation (.json, .mo) to your python package. This can be done by editing these two files.
+
+setup.py:
+
+.. code:: python
+
+    from setuptools import setup
+
+    setup(
+        # ...
+        entry_points={"jupyterlab.locale": ["jupyterlab_some_package = jupyterlab_some_package"]},
+    )
+
+
+MANIFEST.in:
+
+.. code:: text
+
+    recursive-include jupyterlab_some_package *.json
+    recursive-include jupyterlab_some_package *.mo
+
+.. note::
+   An example is available in the `server test <https://github.com/jupyterlab/jupyterlab_server/tree/main/tests/translations/jupyterlab-some-package>`_
 
 Settings translation
 --------------------