diff --git a/gerrit/projects.yaml b/gerrit/projects.yaml index 9362028f07..4161a16a2b 100755 --- a/gerrit/projects.yaml +++ b/gerrit/projects.yaml @@ -5135,6 +5135,8 @@ description: Repository containing OpenStack repositories - project: openstack/openstack-ansible description: Ansible playbooks for deploying OpenStack. + options: + - translate - project: openstack/openstack-ansible-apt_package_pinning description: Role apt_package_pinning for OpenStack-Ansible groups: @@ -5494,6 +5496,8 @@ - openstack-helm description: Helm charts for deploying OpenStack on Kubernetes use-storyboard: true + options: + - translate - project: openstack/openstack-helm-addons use-storyboard: true groups: diff --git a/roles/prep-zanata/files/common_translation_update.sh b/roles/prep-zanata/files/common_translation_update.sh index ec24c29c71..8c0a37e4ff 100644 --- a/roles/prep-zanata/files/common_translation_update.sh +++ b/roles/prep-zanata/files/common_translation_update.sh @@ -417,6 +417,51 @@ function extract_messages_django { done } +# Extract doc messages +function extract_messages_doc { + # Temporary build folder for gettext + mkdir -p doc/build/gettext + + # Extract messages + sphinx-build -b gettext doc/source \ + doc/build/gettext/ + # Manipulates pot translation sources if needed + if [[ -f tools/doc-pot-filter.sh ]]; then + tools/doc-pot-filter.sh + fi + + # New translation target projects may not have locale folder + mkdir -p doc/source/locale + + # Sphinx builds a pot file for each directory and for each file + # in the top-level directory. + # We keep the directory files and concatenate all top-level files. + local has_other=0 + for f in doc/build/gettext/*.pot; do + local fn=$(basename $f .pot) + # If a pot file corresponds to a directory, we use the pot file as-is. + if [ -d doc/source/$fn ]; then + # Remove UUIDs, those are not necessary and change too often + msgcat --use-first --sort-by-file $f | \ + awk '$0 !~ /^\# [a-z0-9]+$/' > doc/source/locale/doc-$fn.pot + rm $f + else + has_other=1 + fi + done + + # We concatenate remaining into a single pot file so that + # "git add ${DIRECTORY}/source/locale" will only add a + # single pot file for all top-level files. + if [ "$has_other" = "1" ]; then + # Remove UUIDs, those are not necessary and change too often + msgcat --use-first --sort-by-file doc/build/gettext/*.pot | \ + awk '$0 !~ /^\# [a-z0-9]+$/' > doc/source/locale/doc.pot + fi + + rm -rf doc/build/gettext/ +} + # Extract releasenotes messages function extract_messages_releasenotes { local keep_workdir=$1 diff --git a/roles/prep-zanata/files/upstream_translation_update.sh b/roles/prep-zanata/files/upstream_translation_update.sh index bafcfabe50..5416032af4 100755 --- a/roles/prep-zanata/files/upstream_translation_update.sh +++ b/roles/prep-zanata/files/upstream_translation_update.sh @@ -114,6 +114,15 @@ case "$PROJECT" in ALL_MODULES="$modulename $ALL_MODULES" done fi + # ---- Documentation ---- + # Let's test this with some repos :) + DOC_TARGETS=('horizon' 'openstack-ansible' 'openstack-helm') + if [[ -f doc/source/conf.py ]]; then + if [[ ${DOC_TARGETS[*]} =~ "$PROJECT" ]]; then + extract_messages_doc + ALL_MODULES="doc $ALL_MODULES" + fi + fi ;; esac diff --git a/zuul.d/projects.yaml b/zuul.d/projects.yaml index ca87dd0dfd..4aad624383 100644 --- a/zuul.d/projects.yaml +++ b/zuul.d/projects.yaml @@ -11109,6 +11109,7 @@ - publish-openstack-sphinx-docs - deploy-guide-jobs - release-notes-jobs + - translation-jobs release: jobs: - announce-release @@ -11722,6 +11723,7 @@ templates: - system-required - publish-openstack-sphinx-docs + - translation-jobs - project: name: openstack/openstack-helm-addons