diff --git a/.github/workflows/validate-translation-files.yml b/.github/workflows/validate-translation-files.yml new file mode 100644 index 00000000000..62f90f150cb --- /dev/null +++ b/.github/workflows/validate-translation-files.yml @@ -0,0 +1,23 @@ +# Validate the po files to ensure translation files are compilable. + +name: Validate translation PO files + +on: + - pull_request + +jobs: + validate-po-files: + runs-on: ubuntu-latest + steps: + # Clones the openedx-translations repo + - name: clone openedx/openedx-translations + uses: actions/checkout@v3 + + - name: Install gettext + run: | + sudo apt install -y gettext + + - name: Validate translation files + id: validate_translation_files + run: | + make validate_translation_files diff --git a/.gitignore b/.gitignore index 18ec9cd7013..6da04169ce6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ __pycache__ .pytest_cache +# msgfmt sometimes leaves these behind in the root directory +/*.mo diff --git a/Makefile b/Makefile index 3f2a5d9fc4c..69e63906b05 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: piptools upgrade fix_transifex_resource_names transifex_resources_requirements +.PHONY: piptools upgrade fix_transifex_resource_names transifex_resources_requirements validate_translation_files piptools: pip install -q -r requirements/pip_tools.txt @@ -29,3 +29,11 @@ test_requirements: ## Installs test.txt requirements test: ## Run scripts tests pytest -v -s scripts/tests + +validate_translation_files: ## Run basic validation to ensure files are compilable + find translations/ -name '*.po' \ + | grep -v '/en/LC_MESSAGES/' \ + | xargs -I{} msgfmt -v --strict --check {} + @echo '-----------------------------------------' + @echo 'Congratulations! Translation files are valid.' + @echo '-----------------------------------------'