Alexandre Lision | 922380d | 2015-09-15 10:25:17 -0400 | [diff] [blame] | 1 | #!/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 Lision | 4f187a3 | 2015-10-13 16:24:53 -0400 | [diff] [blame] | 26 | |
| 27 | if [ "$(uname)" == "Darwin" ]; then |
| 28 | option="-I" |
| 29 | else |
| 30 | option="-i" |
| 31 | fi |
| 32 | |
Alexandre Lision | fe5525e | 2015-12-14 14:41:26 -0500 | [diff] [blame] | 33 | # don't fail on unknown byte sequences |
| 34 | export LC_CTYPE=C |
| 35 | |
Guillaume Roguez | 2800973 | 2016-06-23 00:19:37 -0400 | [diff] [blame] | 36 | tx pull -af --minimum-perc=1 |
Alexandre Lision | 922380d | 2015-09-15 10:25:17 -0400 | [diff] [blame] | 37 | cd ui/ |
| 38 | |
Alexandre Lision | 4f187a3 | 2015-10-13 16:24:53 -0400 | [diff] [blame] | 39 | for dir in `find . -name "*.lproj" -type d`; do |
Alexandre Lision | 922380d | 2015-09-15 10:25:17 -0400 | [diff] [blame] | 40 | cd $dir |
Alexandre Lision | 004ccbb | 2015-09-17 09:34:51 -0400 | [diff] [blame] | 41 | echo "$dir..." |
Alexandre Lision | 922380d | 2015-09-15 10:25:17 -0400 | [diff] [blame] | 42 | # in each country dir cleanup the files |
| 43 | for file in `find . -name '*.strings'`; do |
| 44 | # Convert file if encoding is utf-16le |
Alexandre Lision | 4f187a3 | 2015-10-13 16:24:53 -0400 | [diff] [blame] | 45 | if [ `file $option $file | awk '{print $3;}'` = "charset=utf-16le" ]; then |
Alexandre Lision | 004ccbb | 2015-09-17 09:34:51 -0400 | [diff] [blame] | 46 | echo "Converting $file..." |
Alexandre Lision | 922380d | 2015-09-15 10:25:17 -0400 | [diff] [blame] | 47 | 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 Lision | 004ccbb | 2015-09-17 09:34:51 -0400 | [diff] [blame] | 53 | echo "Cleaning up $file" |
Alexandre Lision | 922380d | 2015-09-15 10:25:17 -0400 | [diff] [blame] | 54 | sed '1s/.*//' $file.8 > $file |
| 55 | rm $file.8 |
| 56 | done |
| 57 | cd .. |
| 58 | done |