Bump version number to 0.10.1.
[tor-bridgedb.git] / maint / get-completed-translations
blobe09e28a82348b72d0db3040fb39ddd9f21050667
1 #!/bin/bash
2 # -*- coding: utf-8 -*-
3 #_____________________________________________________________________________
4 # This file is part of BridgeDB, a Tor bridge distribution system.
6 # :authors: Isis Lovecruft 0xA3ADB67A2CDB8B35 <isis@torproject.org>
7 # please also see AUTHORS file
8 # :copyright: (c) 2007-2013, The Tor Project, Inc.
9 # (c) 2007-2013, all entities within the AUTHORS file
10 # :license: 3-clause BSD, see included LICENSE for information
11 #_____________________________________________________________________________
13 # get-completed-translations
14 # --------------------------
15 # This should be used when newly completed translations are available in the
16 # Tor Project's translations repository. [0]
18 # The first time this script is run, it will create a directory, next to the
19 # BridgeDB repository directory, named 'bridgedb-translations':
21 # …/parentdir/
22 # |-- bridgedb/
23 # | |`-- bridgedb/
24 # | | `-- i18n/
25 # | | |-- ar/
26 # | | | `-- LC_MESSAGES
27 # | | | |-- bridgedb.mo
28 # | | | `-- bridgedb.po
29 # | | |-- …
30 # | | |-- zh_CN/
31 # | | | `-- LC_MESSAGES
32 # | | | |-- bridgedb.mo
33 # | | | `-- bridgedb.po
34 # | | `-- templates/
35 # | |-- scripts/
36 # | `-- …
37 # `-- bridgedb-translations/
38 # |-- ar/
39 # | `-- LC_MESSAGES
40 # | `-- bridgedb.po
41 # |-- …
42 # `-- zh_CN/
43 # `-- LC_MESSAGES
44 # `-- bridgedb.po
46 # The new directory, 'bridgedb-translations', will only contain the contents
47 # of the upstream branch 'bridgedb_completed'. The updated .po files will be
48 # rsync'd into the lib/bridgedb/i18n/ directory in the BridgeDB repository
49 # directory.
51 # You shouldn't need to change anything in this script, nor run it from any
52 # specific location. Just run it from anywhere and it'll update the
53 # translations.
55 # [0]: https://gitweb.torproject.org/translation.git
56 #_____________________________________________________________________________
59 # The name of the directory to store completed translations for BridgeDB
60 # in. This will be created, and made to fetch *only* the
61 # $TRANS_COMPLETE_BRANCH branch from the TPO translations.git repo:
62 TRANS_DIR='bridgedb-translations'
64 # The remote location of the translations repo:
65 TRANS_REMOTE='git@git-rw.torproject.org:translation.git'
67 # The branch from the remote translations repo to check out:
68 TRANS_COMPLETED_BRANCH='bridgedb_completed'
71 #-----------------------------------------------------------------------------
72 # Don't touch anything below here unless you're fixing a bug.
73 #_____________________________________________________________________________
75 # Check for dependencies:
76 which rsync 2>&1 >/dev/null || \
77 { printf "You must have rsync installed.\nExiting.\n"; exit 1 ;}
79 # Figure out where we are so that we can get to the parent directory of the
80 # BridgeDB repository directory:
81 THIS_FILE="${BASH_SOURCE[0]}"
82 NAME=$(basename $0)
84 while [ -h "$THIS_FILE" ]; do
85 # resolve $THIS_FILE until the file is no longer a symlink:
86 THIS_PATH="$( cd -P "$( dirname "$THIS_FILE" )" && pwd )"
87 THIS_FILE="$(readlink "$THIS_FILE")"
88 # if $THIS_FILE was a relative symlink, we need to resolve it relative to
89 # the path where the symlink file was located:
90 [[ $THIS_FILE != /* ]] && THIS_FILE="$THIS_PATH/$THIS_FILE"
91 done
93 THIS_PATH="$( cd -P "$( dirname "$THIS_FILE" )" && pwd )"
94 PARENT_PATH=${THIS_PATH%%/bridgedb/maint}
96 function usage () {
97 printf "Usage: %s\n\n" $NAME
98 printf "That's it. Just run it from anywhere. There are no options.\n"
99 printf "\n"
100 printf "This should be used when newly completed translations are available in the\n"
101 printf "Tor Project's translations repository.\n"
102 printf "\n"
103 printf "The first time this script is run, it will create a directory, next to the\n"
104 printf "BridgeDB repository directory, named 'bridgedb-translations'.\n"
105 printf "The new directory, 'bridgedb-translations', will only contain the contents\n"
106 printf "of the upstream branch 'bridgedb_completed'. The updated .po files will be\n"
107 printf "rsync'd into the lib/bridgedb/i18n/ directory in the BridgeDB repository\n"
108 printf "directory.\n"
109 printf "\n"
112 if test "$#" -gt "1" ; then usage ; fi
114 # Go to the parent directory of the BridgeDB repo:
115 cd $PARENT_PATH
116 #printf "%s: Current working directory:\n\t%s\n" $NAME $PWD
117 # Create a directory for completed translations if it doesn't already exist:
118 if ! test -d "$TRANS_DIR" ; then
119 printf "%s: Creating directory for translations repo:\n\t%s\n" \
120 $NAME $TRANS_DIR
121 mkdir $TRANS_DIR
122 # Go into the completed translations repo:
123 cd $TRANS_DIR
124 # Create the git repo if it doesn't exist:
125 git init
126 git remote add -t $TRANS_COMPLETED_BRANCH -f origin $TRANS_REMOTE
127 git checkout $TRANS_COMPLETED_BRANCH
128 else
129 printf "%s: Found directory for translations repo:\n\t%s\n" \
130 $NAME $TRANS_DIR
131 # Go into the completed translations repo
132 cd $TRANS_DIR
133 git pull
136 cd $PARENT_PATH
137 rsync -PCAXvrq \
138 --filter 'include *bridgedb.po' \
139 --filter 'exclude .gitignore' \
140 $TRANS_DIR/* ./bridgedb/bridgedb/i18n/
141 status=$?
143 printf "\n"
144 read -N1 -t15 -p"Should we recompile the new translations now? (Y/n) " choice
145 printf "\n"
147 case $choice in
148 n )
149 printf "Skipping translations recompilation...\n\n"
150 status=$?
153 printf "Recompiling files from *.po → *.mo ...\n\n"
154 cd ${PARENT_PATH}'/bridgedb'
155 python setup.py compile_catalog
156 status=$?
157 printf "\n"
158 printf "Don't forget to reinstall BridgeDB to update the templates!\n\n"
160 esac
162 exit $status