2 # Use this script to facilitate most common jobs related with transifex-client.
3 # ----------------------------------------------------------------------------
4 # 2014 Written by filux <heross(@@)o2.pl>
5 # Copyright (c) 2014-2015 under GNU GPL v3.0+
7 CURRENTDIR
="$(dirname "$
(readlink
-f "$0")")"
9 if [ "$1" = "--help" ]; then
10 echo -e "\n Use this script to facilitate most common jobs related with transifex-client.
11 In default (without parameters) script performs update of all translations.\n
12 Usage: tx.sh [OPTION].
13 available options (only one at once):
14 '... --release' - pull with abandonment of insufficiently complete translations
15 (is worth to use it e.g. just before new release),
16 '... --push' - push to transifex new version of sources,
17 '... --push-all' - push to transifex new version of sources and also improved
18 translations (before this step it's very recommended to use
19 '... --release' first),
20 '... --help' - this text.\n"
22 elif [ "$1" = "--release" ]; then
23 find .
-name "*.lng" -type f
-not -name "english.lng" -not -name "*_english.lng" \
24 -not -name "*_default.lng" |
xargs rm -f
28 tx_pull
="$tx_cl pull -a --skip"
29 tx_push
="$tx_cl push -s --skip"
30 tx_push_all
="$tx_cl push -s -t --skip"
31 if [ "$1" = "--push" ]; then
33 elif [ "$1" = "--push-all" ]; then
35 elif [ "$1" = "" ] ||
[ "$1" = "--release" ]; then
38 lang_list1
="$(find ./data/lang/hint/ -maxdepth 1 -name "*.lng
" -type f -not -name "*english.lng
" \
39 -not -name "*default.lng
")"
40 lang_list2
="$(find . -name "*.lng
" -type f -not -name "*english.lng
" -not -name "*default.lng
" \
41 -not -wholename ".
/data
/lang
/*.lng
")"
42 lang_list
="$(echo -e "$lang_list1\n$lang_list2" | awk -F "/" '{ print $NF }' \
43 | awk -F "_
" '{ print $NF }' | awk '!a[$0]++' | xargs echo)"
44 for s_lang
in $lang_list; do
45 main_lang
="$(find ./data/lang/ -maxdepth 1 -name "$s_lang" -type f | xargs echo)"
46 if [ "$main_lang" = "" ]; then find .
-name "*$s_lang" |
xargs rm -f; fi
49 main_lang2
="$(find ./data/lang/ -maxdepth 1 -name "*.lng
" -type f -not -name "*english.lng
" \
50 -not -name "*default.lng
")"
51 p_lang_list
="$(echo -e "$main_lang2\n$lang_list1\n$lang_list2" | awk -F "/" '{ print $NF }' \
52 | awk -F "_
" '{ print $NF }' | awk -F ".
" '{ print $1 }' | sort -u | xargs echo)"
53 echo -e "\nThe list of currently supported languages in relation to 'lang_map':\n$p_lang_list"
54 echo "If you see something strange on this list, then probably 'lang_map' needs a fix"
55 echo -e "and after that, script should be executed once again with '--release' parameter.\n"
57 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
58 # this part has sed rules from the script Written by Tom Reynolds <tomreyn@megaglest.org>
59 # with Copyright (c) 2012 Tom Reynolds under GNU GPL v3.0
60 files
="$(find . -type f -name *.lng | sort -u | xargs)"
61 for file in $files; do
62 sed -i -e 's/"/"/g' -e 's/„/„/g' -e 's/“/“/g' -e 's/[ \t]*$//' -e 's/^\([^=]*\)=\s*/\1=/' \
63 -e 's/ */ /g' -e 's/ \\n/\\n/g' -e 's/\\n /\\n/g' -e 's/\\n\\n\\n/\\n\\n/g' -e 's/\\n\\n$/\\n/g' "$file"
64 sed -i -e '$a\' "$file"
66 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -