PageRenderTime 28ms CodeModel.GetById 18ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/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
39perforce_path=//depot/google3/research/android/marvin/talkback
40history_file=/home/build/googlemobile/data/Android/history
41xtb_root=/home/build/google3/googledata/transconsole/xtb
42
43# fr it es de nl cs pl ja zh-TW zh-CN ru ko no es-US da el \
44#              tr pt-PT pt rm sv ar bg ca en-GB fi hr hu in iw lt lv ro \
45#              sk sl sr th uk vi fa tl
46
47if ! test -d research/android/marvin/talkback ; then
48  echo 'This must be run from your google3 directory!'
49  exit
50fi
51
52# This is a stupid hack, but it doesn't seem to work unless there's a symlink
53# to talkback named TalkBack (camel case) in the current directory.
54if ! test -L TalkBack ; then
55  ln -s research/android/marvin/talkback TalkBack
56fi
57
58for srclocale in fr it es de nl cs pl ja zh-TW zh-CN ru ko no es-US da el \
59              tr pt-PT pt rm sv ar bg ca en-GB fi hr hu in iw lt lv ro \
60              sk sl sr th uk vi fa tl
61do
62  locale=$srclocale;
63
64  # Convert from a Translation Console locale to an Android (Java) locale.
65  # Borrowed from 'default-to-translation' in the Android internal source.
66  locale=$(echo $locale | sed 's/\([a-z][a-z]\)-\([A-Z][A-Z]\)/\1-r\2/');
67  # Norwegian is NO in the translation console, but NB in Java/ICU locales.
68  locale=$(echo $locale | sed 's/no/nb/');
69
70  echo "TC locale: $srclocale | Android locale: $locale";
71
72  xtb="$xtb_root/AndroidTalkBack/$srclocale.xtb";
73  outdir="research/android/marvin/talkback/res/values-$locale";
74  mkdir -p $outdir
75  for strings in arrays.xml \
76                 strings.xml \
77                 strings_googletv.xml \
78                 strings_thirdparty.xml
79  do
80    infile="TalkBack/res/values/$strings";
81    outfile="$outdir/$strings";
82    echo "Creating $outfile"
83    #g4 edit "$outfile" > /dev/null 2>&1 ;
84    transconsole -m $perforce_path TalkBack -p AndroidTalkBack \
85        -h $history_file -i $xtb $infile > $outfile ;
86    #g4 add $outfile  > /dev/null 2>&1 ;
87  done
88done