blob: 46f0f7f4faafe0007516c715e39487afb956d00a [file] [log] [blame]
Alexandre Lision922380d2015-09-15 10:25:17 -04001#!/bin/bash
2
Sébastien Blin029ffa82019-01-02 17:43:48 -05003# Copyright (C) 2015-2019 Savoir-faire Linux Inc.
Alexandre Lision922380d2015-09-15 10:25:17 -04004# 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 generates .strings files for Base language (e.g: english)
21# These files are encoded in UTF-16LE which is interpreted as binary in Git,
22# and therefore not visible when using 'git diff'
23
24echo "Regenerating Localizable.strings..."
25find src -name '*.mm' | xargs genstrings -o ui/Base.lproj
26iconv -f UTF-16LE -t UTF-8 ui/Base.lproj/Localizable.strings > ui/Base.lproj/Localizable.strings.8
27sed '1s/.*//' ui/Base.lproj/Localizable.strings.8 > ui/Base.lproj/Localizable.strings
28rm ui/Base.lproj/Localizable.strings.8
29
30# generate strings from XIBs
31
32for file in `find ui -name '*.xib' -and -path '*/Base.lproj/*'`; do
33 strings_file=`echo $file | sed s/\.xib/.strings/`
34 echo "Regenerating $strings_file..."
35 ibtool --generate-strings-file $strings_file $file
36
37 # Change file encoding
38 iconv -f UTF-16LE -t UTF-8 $strings_file > $strings_file.8
39
40 # Empty first line
41 sed '1s/.*//' $strings_file.8 > $strings_file
42 rm $strings_file.8
43done