From 3f1ef8936ae16fbd96bcc0a1f4d9666c1c1741ee Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Sun, 30 Jul 2023 18:42:03 +0300 Subject: [PATCH] feat: use `atlas` in `make pull_translations` This contribution is part of the [FC-0012 project](https://openedx.atlassian.net/l/cp/XGS0iCcQ) which is sparked by the [Translation Infrastructure update OEP-58](https://open-edx-proposals.readthedocs.io/en/latest/architectural-decisions/oep-0058-arch-translations-management.html#specification). --- Dockerfile | 3 ++- Makefile | 14 ++++++++++++++ requirements/base.in | 1 + requirements/local.txt | 2 ++ requirements/production.txt | 2 ++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bb3b9109db9..657fb542e34 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,9 @@ FROM ubuntu:focal as app ENV DEBIAN_FRONTEND noninteractive # System requirements. RUN apt update && \ - apt-get install -qy \ + apt-get install -qy \ curl \ + gettext \ # required by bower installer git \ language-pack-en \ diff --git a/Makefile b/Makefile index 836e54cd73c..a7bb0eebed5 100644 --- a/Makefile +++ b/Makefile @@ -95,6 +95,9 @@ migrate: ## Apply database migrations html_coverage: ## Generate and view HTML coverage report coverage html && open htmlcov/index.html +compile_translations: ## Compile .po files to .mo files + cd course_discovery && PYTHONPATH="..:${PYTHONPATH}" django-admin.py compilemessages + # This Make target should not be removed since it is relied on by a Jenkins job (`edx-internal/tools-edx-jenkins/translation-jobs.yml`), using `ecommerce-scripts/transifex`. extract_translations: ## Extract strings to be translated, outputting .po and .mo files # NOTE: We need PYTHONPATH defined to avoid ImportError(s) on CI. @@ -104,8 +107,19 @@ extract_translations: ## Extract strings to be translated, outputting .po and .m cd course_discovery && PYTHONPATH="..:${PYTHONPATH}" django-admin.py compilemessages # This Make target should not be removed since it is relied on by a Jenkins job (`edx-internal/tools-edx-jenkins/translation-jobs.yml`), using `ecommerce-scripts/transifex`. +ifeq ($(OPENEDX_ATLAS_PULL),) pull_translations: ## Pull translations from Transifex tx pull -a -f -t --mode reviewed --minimum-perc=1 +else +# Experimental: OEP-58 Pulls translations using atlas +pull_translations: + find course_discovery/conf/locale -mindepth 1 -maxdepth 1 -type d -exec rm -r {} \; + atlas pull $(OPENEDX_ATLAS_ARGS) translations/course-discovery/course_discovery/conf/locale:course_discovery/conf/locale + python manage.py compilemessages + + @echo "Translations pulled from Transifex and compiled." + @echo "'make static' or 'make static.dev' is required to update the js i18n files." +endif # This Make target should not be removed since it is relied on by a Jenkins job (`edx-internal/tools-edx-jenkins/translation-jobs.yml`), using `ecommerce-scripts/transifex`. push_translations: ## Push source translation files (.po) to Transifex diff --git a/requirements/base.in b/requirements/base.in index 1b18c8b7437..4d9ae033aeb 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -65,6 +65,7 @@ html2text lxml jsonfield markdown +openedx-atlas pillow pycountry python-dateutil diff --git a/requirements/local.txt b/requirements/local.txt index 1fd2fd34855..8c5cb472ce5 100644 --- a/requirements/local.txt +++ b/requirements/local.txt @@ -558,6 +558,8 @@ oauthlib==3.2.2 # social-auth-core openai==0.27.8 # via taxonomy-connector +openedx-atlas==0.4.4 + # via -r requirements/base.in openedx-events==8.5.0 # via # edx-event-bus-kafka diff --git a/requirements/production.txt b/requirements/production.txt index d71f5b29d72..e3b37fbe3bf 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -447,6 +447,8 @@ oauthlib==3.2.2 # social-auth-core openai==0.27.8 # via taxonomy-connector +openedx-atlas==0.4.4 + # via -r requirements/base.in openedx-events==8.5.0 # via # edx-event-bus-kafka