blob: e078bba655bfc78cf3a86cf7c28ca50ae95fab5f [file] [log] [blame]
Alexandre Lision922380d2015-09-15 10:25:17 -04001#!/bin/bash
2
3# Copyright (C) 2015 Savoir-faire Linux Inc.
4# Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20# This scripts pulls translations from transifex
21# It also converts files to UTF-8 and replace the first line which contains a
22# corrupted BMO (byte order mark) placed by Transifex
23
24# Get the translations from Transifex
25# TODO: add contraints on what we pull
Alexandre Lision4f187a32015-10-13 16:24:53 -040026
27if [ "$(uname)" == "Darwin" ]; then
28 option="-I"
29else
30 option="-i"
31fi
32
Alexandre Lisionfe5525e2015-12-14 14:41:26 -050033# don't fail on unknown byte sequences
34export LC_CTYPE=C
35
Guillaume Roguez28009732016-06-23 00:19:37 -040036tx pull -af --minimum-perc=1
Alexandre Lision922380d2015-09-15 10:25:17 -040037cd ui/
38
Alexandre Lision4f187a32015-10-13 16:24:53 -040039for dir in `find . -name "*.lproj" -type d`; do
Alexandre Lision922380d2015-09-15 10:25:17 -040040 cd $dir
Alexandre Lision004ccbb2015-09-17 09:34:51 -040041 echo "$dir..."
Alexandre Lision922380d2015-09-15 10:25:17 -040042 # in each country dir cleanup the files
43 for file in `find . -name '*.strings'`; do
44 # Convert file if encoding is utf-16le
Alexandre Lision4f187a32015-10-13 16:24:53 -040045 if [ `file $option $file | awk '{print $3;}'` = "charset=utf-16le" ]; then
Alexandre Lision004ccbb2015-09-17 09:34:51 -040046 echo "Converting $file..."
Alexandre Lision922380d2015-09-15 10:25:17 -040047 iconv -f UTF-16LE -t UTF-8 $file > $file.8
48 else
49 mv $file $file.8
50 fi
51
52 # Empty first line
Alexandre Lision004ccbb2015-09-17 09:34:51 -040053 echo "Cleaning up $file"
Alexandre Lision922380d2015-09-15 10:25:17 -040054 sed '1s/.*//' $file.8 > $file
55 rm $file.8
56 done
57 cd ..
58done