From 5818881ef640ee3c4bd5d9f1fab81ba38c0a9b99 Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Fri, 21 Jun 2024 11:42:09 +0300 Subject: [PATCH] chore: validate plurals in strings.xml --- .github/workflows/unit_tests.yml | 23 +++++++++++++++++++++++ Makefile | 13 +++++++++++++ 2 files changed, 36 insertions(+) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index fe5aa5869..e193dbc34 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -48,3 +48,26 @@ jobs: name: failures path: app/build/reports/ retention-days: 5 + + translation_strings: + name: Validate strings.xml + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout + + - name: Use Python + uses: actions/python + + - name: Install translations requirements + run: make translation_requirements + + - name: Validate English plurals in strings.xml + run: make validate_english_plurals + + - name: Test extract strings + run: | + make extract_translations + # Ensure the file is extracted + test -f i18n/src/main/res/values/strings.xml diff --git a/Makefile b/Makefile index e7ff3745b..a0ba67b45 100644 --- a/Makefile +++ b/Makefile @@ -10,3 +10,16 @@ pull_translations: clean_translations_temp_directory extract_translations: clean_translations_temp_directory python3 i18n_scripts/translation.py --combine + +validate_english_plurals: + @if git grep 'quantity' -- '**/res/values/strings.xml' | grep -E 'quantity=.(zero|two|few|many)'; then \ + echo ""; \ + echo ""; \ + echo "Error: Found invalid plurals in the files listed above."; \ + echo " Please only use 'one' and 'other' in English strings.xml files,"; \ + echo " otherwise Transifex fails to parse them."; \ + echo ""; \ + exit 1; \ + else \ + echo "strings.xml files are valid."; \ + fi