Created
April 4, 2019 12:13
-
-
Save everlof/17043de217c78f7d1310a7f4b1cc9f7a to your computer and use it in GitHub Desktop.
Read a random text from your Xcode's localization files with the correct language
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
# say -v Daniel `curl -s http://whatthecommit.com/index.txt` | |
RANDOM_FILE=$(shuf -n 1 <(find . -name "*strings" ! -path "*DerivedData*" ! -path "*git*" -path "*Localizable*")) | |
LANGUAGE_CODE=$(echo "${RANDOM_FILE}" | sed -E 's#.*/(.*)\.lproj.*#\1#' | tr '-' '_') | |
if [ ${#LANGUAGE_CODE} -eq 2 ] ; then | |
LANGUAGE_CODE="${LANGUAGE_CODE}_" | |
fi | |
WHO=$(say -v ? | grep "${LANGUAGE_CODE}" | shuf -n 1 | cut -f 1 -d ' ') | |
TO_SAY=$(cat "${RANDOM_FILE}" | sed -n 's/^\(".*\)/\1/p' | cut -f 2 -d = | shuf -n 1) | |
echo "Who ${WHO}" | |
echo "To say: ${TO_SAY}" | |
say -v "${WHO}" "${TO_SAY}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment