tx-pull-translations.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. tx pull --source --translations --all --force
  24. for (( i=0; i<${#IOS_TRANSLATIONS[@]}; i++ )) {
  25. LANG_DIR=`echo ${IOS_TRANSLATIONS[i]} | awk -F '.lproj' '{print $1}' | rev | cut -d '/' -f1 | rev`
  26. OUTPUT_DIR=`echo ${IOS_TRANSLATIONS[i]} | sed 's/\/Localizable.strings//g'`
  27. #echo "convertTranslations: $TMP_ANDROID_TRANSLATIONS/$LANG_DIR/strings.xml -> ${IOS_TRANSLATIONS[i]} (${OUTPUT_DIR})"
  28. if [[ $LANG_DIR == "en" && -f untranslated.xml ]]
  29. then
  30. node convertTranslations.js $TMP_ANDROID_TRANSLATIONS/$LANG_DIR/strings.xml untranslated.xml ${OUTPUT_DIR}
  31. else
  32. node convertTranslations.js $TMP_ANDROID_TRANSLATIONS/$LANG_DIR/strings.xml ${OUTPUT_DIR}
  33. fi
  34. }
  35. rm -rf $TMP_ANDROID_TRANSLATIONS
  36. cd ..