[FIX] translate the documentation

Monkeypatch the docname_to_domain to avoid having one big "application.pot" file
This commit is contained in:
Martin Trigaux 2021-05-06 16:55:55 +02:00
parent 1a0c122500
commit 769f5d9728
2 changed files with 10 additions and 6 deletions

View File

@ -55,13 +55,10 @@ latexpdf:
cp $(BUILD_DIR)/latex/*.pdf $(BUILD_DIR)/html/
@echo "Build finished."
l10n:
gettext:
@echo "Generating translatable files..."
$(SPHINX_BUILD) -c $(CONFIG_DIR) -b gettext $(SOURCE_DIR) $(BUILD_DIR)/gettext
$(SPHINX_BUILD) -c $(CONFIG_DIR) -b gettext $(SOURCE_DIR) locale/sources
@echo "Generation finished."
@echo "Localizing translation strings..."
sphinx-intl update -p $(BUILD_DIR)/gettext -l $(L10N_LANGUAGES)
@echo "Localization finished."
extensions/odoo_theme/static/style.css: extensions/odoo_theme/static/style.scss extensions/odoo_theme/static/scss/*.scss
@echo "Compiling stylesheets..."

View File

@ -5,6 +5,7 @@ from pathlib import Path
from pygments.lexers import JsonLexer, XmlLexer
from sphinx.util import logging
import sphinx
_logger = logging.getLogger(__name__)
@ -128,7 +129,13 @@ intersphinx_mapping = {
github_user = 'odoo'
github_project = 'documentation'
locale_dirs = ['locale/']
locale_dirs = ['../locale/']
# custom docname_to_domain to devide the translations of applications in subdirectories
sphinx.transforms.i18n.docname_to_domain = (
sphinx.util.i18n.docname_to_domain
) = lambda docname, compact: docname.split('/')[1 if docname.startswith('applications/') else 0]
supported_languages = {
'de': 'Deutsch',
'en': 'English',