update-translations.sh 1.82 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#!/bin/bash

#  Copyright (C) 2015 Savoir-faire Linux Inc.
#  Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.

# This scripts pulls translations from transifex
# It also converts files to UTF-8 and replace the first line which contains a
# corrupted BMO (byte order mark) placed by Transifex

# Get the translations from Transifex
# TODO: add contraints on what we pull
26 27 28 29 30 31 32

if [ "$(uname)" == "Darwin" ]; then
    option="-I"
else
    option="-i"
fi

33 34 35
# don't fail on unknown byte sequences
export LC_CTYPE=C

Guillaume Roguez's avatar
Guillaume Roguez committed
36
tx pull -af --minimum-perc=1
37 38
cd ui/

39
for dir in `find . -name "*.lproj" -type d`; do
40
    cd $dir
41
    echo "$dir..."
42 43 44
    # in each country dir cleanup the files
    for file in `find . -name '*.strings'`; do
        # Convert file if encoding is utf-16le
45
        if [ `file $option $file | awk '{print $3;}'` = "charset=utf-16le" ]; then
46
            echo "Converting $file..."
47 48 49 50 51 52
            iconv -f UTF-16LE -t UTF-8 $file > $file.8
        else
            mv $file $file.8
        fi

        # Empty first line
53
        echo "Cleaning up $file"
54 55 56 57 58
        sed '1s/.*//' $file.8 > $file
        rm $file.8
    done
    cd ..
done