I am working on Crowdin client js api to fetch translated strings from Crowdin. I have implemented upload of strings from res dir to crowdin, download of translated strings from Crowdin and update of localized strings to android res dir.
But the issues I am trying to fix is that how the strings format errors can be found and fixed? There are shell script to do that but it does work on plurals
and some more strings.
if grep -RHn "%1$ s" res/values*; then
echo "Found '%1$ s'-related error"
EXIT_STATUS=$((EXIT_STATUS + 1));
fi
if grep -RHn "%1$ d" res/values*; then
echo "Found '%1$ s'-related error"
EXIT_STATUS=$((EXIT_STATUS + 1));
fi
if grep -RHn "%1" res/values* | grep -v "%1\\$"; then
echo "Found '%1'-related error"
EXIT_STATUS=$((EXIT_STATUS + 1));
fi
if grep -RHn '%' res/values* |
sed -e 's/%/\n%/g' | # Split lines that contain several expressions
grep '%' | # Filter out lines that do not contain expressions
grep -v ' n% ' | # Lone % character, not a variable
grep -v '(n%)' | # Lone % character, not a variable
grep -v 'n%<' | # Same, at the end of the string
grep -v '>n% ' | # Same, at the beginning of the string
grep -v '%で' | # Same, no spaces in Japanese
grep -v '%s' | # Single string variable
grep -v '%d' | # Single decimal variable
grep -v '%[0-9][0-9]\?$s' | # Multiple string variable
grep -v '%[0-9][0-9]\?$d' | # Multiple decimal variable
grep -v '%1$.1f' | # ?
grep -v '%.1f' |
grep -v '%\\n' |
then
echo "Found grep errors but if you are not on macOS they are likely false positive. Ignoring"
#EXIT_STATUS=$((EXIT_STATUS + 1))
fi
Can gradle lint be used to find errors for format in localized strings?