/TalkBack/import_translations.sh

http://eyes-free.googlecode.com/ · Shell · 88 lines · 33 code · 8 blank · 47 comment · 4 complexity · 2e37cc5e751f39b6e0dfbb425f512fbc MD5 · raw file

  1. #!/bin/sh
  2. #
  3. # This script imports the translations from the Translation Console into
  4. # TalkBack. It puts the resulting files directly into the res/values-??/
  5. # directories and does a g4 add or g4 edit on them, but you have to create
  6. # the changelist to submit the changes.
  7. #
  8. # Note that the translation system that Android uses is different than other
  9. # systems in google3, so a special android-internal tool must be built and
  10. # used. Here are the full instructions, from scratch:
  11. #
  12. # 1. Get android-internal
  13. #
  14. # 2. Compile all of Android
  15. #
  16. # bash
  17. # source build/envsetup.sh
  18. # make -j 8
  19. # wait an hour
  20. #
  21. # 3. It's okay if something fails, but make sure transconsole is compiled:
  22. #
  23. # mmm vendor/google/tools/transconsole
  24. #
  25. # 4. Add out/host/linux-x86/bin to your path (transconsole is there)
  26. #
  27. # 5. Update the list of locales below, look at the file
  28. # vendor/google/tools/localization/import-from-xtb in the android-internal
  29. # source to get the best list.
  30. #
  31. # 6. Update the list of xml files containing strings (look in res/values/
  32. # inside TalkBack)
  33. #
  34. # 7. Now run this script from your google3 directory like this:
  35. # sh research/android/marvin/talkback/import_translations.sh
  36. #
  37. # 8. Make a changelist with research/android/marvin/talkback/res/...
  38. perforce_path=//depot/google3/research/android/marvin/talkback
  39. history_file=/home/build/googlemobile/data/Android/history
  40. xtb_root=/home/build/google3/googledata/transconsole/xtb
  41. # fr it es de nl cs pl ja zh-TW zh-CN ru ko no es-US da el \
  42. # tr pt-PT pt rm sv ar bg ca en-GB fi hr hu in iw lt lv ro \
  43. # sk sl sr th uk vi fa tl
  44. if ! test -d research/android/marvin/talkback ; then
  45. echo 'This must be run from your google3 directory!'
  46. exit
  47. fi
  48. # This is a stupid hack, but it doesn't seem to work unless there's a symlink
  49. # to talkback named TalkBack (camel case) in the current directory.
  50. if ! test -L TalkBack ; then
  51. ln -s research/android/marvin/talkback TalkBack
  52. fi
  53. for srclocale in fr it es de nl cs pl ja zh-TW zh-CN ru ko no es-US da el \
  54. tr pt-PT pt rm sv ar bg ca en-GB fi hr hu in iw lt lv ro \
  55. sk sl sr th uk vi fa tl
  56. do
  57. locale=$srclocale;
  58. # Convert from a Translation Console locale to an Android (Java) locale.
  59. # Borrowed from 'default-to-translation' in the Android internal source.
  60. locale=$(echo $locale | sed 's/\([a-z][a-z]\)-\([A-Z][A-Z]\)/\1-r\2/');
  61. # Norwegian is NO in the translation console, but NB in Java/ICU locales.
  62. locale=$(echo $locale | sed 's/no/nb/');
  63. echo "TC locale: $srclocale | Android locale: $locale";
  64. xtb="$xtb_root/AndroidTalkBack/$srclocale.xtb";
  65. outdir="research/android/marvin/talkback/res/values-$locale";
  66. mkdir -p $outdir
  67. for strings in arrays.xml \
  68. strings.xml \
  69. strings_googletv.xml \
  70. strings_thirdparty.xml
  71. do
  72. infile="TalkBack/res/values/$strings";
  73. outfile="$outdir/$strings";
  74. echo "Creating $outfile"
  75. #g4 edit "$outfile" > /dev/null 2>&1 ;
  76. transconsole -m $perforce_path TalkBack -p AndroidTalkBack \
  77. -h $history_file -i $xtb $infile > $outfile ;
  78. #g4 add $outfile > /dev/null 2>&1 ;
  79. done
  80. done