tx-pull-translations.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. # This script pulls android translations from transifex and converts them to apple strings files.
  3. # Credits to Daniel Cohen Gindi.
  4. # ----Main-----
  5. cd scripts
  6. TMP_ANDROID_TRANSLATIONS=tmpAndroidTranslations
  7. if [[ -z `which node` ]]
  8. then
  9. echo "ERROR: You need to have node installed. Exiting."
  10. exit
  11. fi
  12. if [[ -z `which tx` ]]
  13. then
  14. echo "ERROR: You need to have tx installed. Exiting."
  15. exit
  16. fi
  17. if [[ -d $TMP_ANDROID_TRANSLATIONS ]]
  18. then
  19. rm -rf $TMP_ANDROID_TRANSLATIONS
  20. fi
  21. IOS_TRANSLATIONS=( $(find .. -name Localizable.strings) )
  22. mkdir $TMP_ANDROID_TRANSLATIONS
  23. cd $TMP_ANDROID_TRANSLATIONS
  24. tx pull --all --source
  25. cd ..
  26. for (( i=0; i<${#IOS_TRANSLATIONS[@]}; i++ )) {
  27. LANG_DIR=`echo ${IOS_TRANSLATIONS[i]} | awk -F '.lproj' '{print $1}' | rev | cut -d '/' -f1 | rev`
  28. OUTPUT_DIR=`echo ${IOS_TRANSLATIONS[i]} | sed 's/\/Localizable.strings//g'`
  29. #echo "convertTranslations: $TMP_ANDROID_TRANSLATIONS/$LANG_DIR/strings.xml -> ${IOS_TRANSLATIONS[i]} (${OUTPUT_DIR})"
  30. if [[ $LANG_DIR == "en" && -f untranslated.xml ]]
  31. then
  32. node convertTranslations.js $TMP_ANDROID_TRANSLATIONS/$LANG_DIR/strings.xml untranslated.xml ${OUTPUT_DIR}
  33. else
  34. node convertTranslations.js $TMP_ANDROID_TRANSLATIONS/$LANG_DIR/strings.xml ${OUTPUT_DIR}
  35. fi
  36. }
  37. rm -rf $TMP_ANDROID_TRANSLATIONS
  38. cd ..