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':
26 # | | | `-- LC_MESSAGES
27 # | | | |-- bridgedb.mo
28 # | | | `-- bridgedb.po
31 # | | | `-- LC_MESSAGES
32 # | | | |-- bridgedb.mo
33 # | | | `-- bridgedb.po
37 # `-- bridgedb-translations/
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
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
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]}"
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"
93 THIS_PATH
="$( cd -P "$
( dirname "$THIS_FILE" )" && pwd )"
94 PARENT_PATH
=${THIS_PATH%%/bridgedb/maint}
97 printf "Usage: %s\n\n" $NAME
98 printf "That's it. Just run it from anywhere. There are no options.\n"
100 printf "This should be used when newly completed translations are available in the\n"
101 printf "Tor Project's translations repository.\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"
112 if test "$#" -gt "1" ; then usage
; fi
114 # Go to the parent directory of the BridgeDB repo:
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" \
122 # Go into the completed translations repo:
124 # Create the git repo if it doesn't exist:
126 git remote add
-t $TRANS_COMPLETED_BRANCH -f origin
$TRANS_REMOTE
127 git checkout
$TRANS_COMPLETED_BRANCH
129 printf "%s: Found directory for translations repo:\n\t%s\n" \
131 # Go into the completed translations repo
138 --filter 'include *bridgedb.po' \
139 --filter 'exclude .gitignore' \
140 $TRANS_DIR/* .
/bridgedb
/bridgedb
/i18n
/
144 read -N1 -t15 -p"Should we recompile the new translations now? (Y/n) " choice
149 printf "Skipping translations recompilation...\n\n"
153 printf "Recompiling files from *.po → *.mo ...\n\n"
154 cd ${PARENT_PATH}'/bridgedb'
155 python setup.py compile_catalog
158 printf "Don't forget to reinstall BridgeDB to update the templates!\n\n"