From 769f5d9728a1a8bf960d2674cf68b0a0e5c92b03 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 6 May 2021 16:55:55 +0200 Subject: [PATCH] [FIX] translate the documentation Monkeypatch the docname_to_domain to avoid having one big "application.pot" file --- Makefile | 7 ++----- conf.py | 9 ++++++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index a3ddf23ac..02ca83d8d 100644 --- a/Makefile +++ b/Makefile @@ -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..." diff --git a/conf.py b/conf.py index 922709e57..9499ec7bb 100644 --- a/conf.py +++ b/conf.py @@ -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',