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 db17b43
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/validate-english-strings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Validate English strings.xml

on:
pull_request: { }
push:
branches: [ main, develop ]

jobs:
tests:
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 db17b43

Please sign in to comment.