Skip to content

Commit

Permalink
chore: validate plurals in strings.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarIthawi committed Jun 21, 2024
1 parent 05c3544 commit 5818881
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5818881

Please sign in to comment.