Commits

defnull  committed 5f86c57

docs: Prepared multi-lingual documentation.

  • Participants
  • Parent commits e2cedf2

Comments (0)

Files changed (3)

File docs/_locale/README.txt

+======================
+Requirements and Setup
+======================
+
+You need python-sphinx (pip install sphinx) and gettext (for msgmerge and msgfmt).
+A translation file editor (e.g. poedit) helps a lot.
+
+Translation Workflow
+====================
+
+Run docs/_locale/update.sh before and after editing *.po files to merge new
+sentences and check for errors.
+
+Do not add *.mo files to the repository, even if your editor creates them.
+We only need the *.po files.
+
+Add a new language
+==================
+
+Add your language (two-letter code) to 'update.sh' and run it. A new
+two-letter directory will appear with all the *.po files in it.

File docs/_locale/update.sh

+#!/bin/bash
+cd "$( cd "$( dirname "$0" )" && pwd )"
+
+LANGUAGES='de cn'
+
+echo 'Generating new POT files ...'
+sphinx-build -b gettext -E .. _pot
+
+echo 'Merging and compiling *.po files ...'
+for LANG in $LANGUAGES; do
+  for POT in _pot/*.pot; do
+    DOC=`basename $POT .pot`
+    echo $LANG/$DOC.po
+    test -d $LANG/LC_MESSAGES || mkdir -p $LANG/LC_MESSAGES
+    test -f $LANG/$DOC.po || cp $POT $LANG/$DOC.po
+    msgmerge --quiet --backup=none -U $LANG/$DOC.po $POT
+    msgfmt $LANG/$DOC.po -o "$LANG/LC_MESSAGES/$DOC.mo"
+  done
+done

File docs/conf.py

 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
 language = 'en'
+locale_dirs = ['_locale']
 
 # There are two options for replacing |today|: either, you set today to some
 # non-false value, then it is used:
 
 autodoc_member_order = 'bysource'
 
-locale_dirs = ['./locale']