forked from duckduckgo/iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloc_import.sh
executable file
·50 lines (40 loc) · 1.37 KB
/
loc_import.sh
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
baseName=$2
if [ $# -ne 2 ]; then
baseName=$(basename "$1")
echo "Choosing $baseName as a base name for translation files"
fi
for dir in "$1"/*; do
echo "Processing $dir"
locale=`basename "$dir"`
targetLocale=$(echo $locale | cut -f1 -d-)
if test -f "$dir/$baseName.xliff"; then
fileName="$baseName.xliff"
echo "Processing $locale xliff"
if [ "$locale" != "$targetLocale" ];
then
echo "Changing locale from '$locale' to '$targetLocale'"
sed -i '.bak' "s/target-language=\"$locale\"/target-language=\"$targetLocale\"/" "$dir/$fileName"
rm "$dir/$fileName.bak"
fi
echo "Importing $dir/$fileName ..."
xcodebuild -importLocalizations -project DuckDuckGo.xcodeproj -localizationPath "$dir/$fileName"
if [ $? -ne 0 ]; then
echo "ERROR: Failed to import $dir/$fileName"
echo
echo "Check translation folder and files then try again."
echo
exit 1
fi
echo "Reverting changes to stringsdict file"
git checkout "DuckDuckGo/$targetLocale.lproj/Localizable.stringsdict"
elif test -f "$dir/$baseName.stringsdict"; then
fileName=$baseName.stringsdict
echo "Processing $locale stringsdict"
cp "$dir/$fileName" "DuckDuckGo/$targetLocale.lproj/Localizable.stringsdict"
else
echo "ERROR: $fileName xlif or stringsdict not found in $dir"
echo
exit 1
fi
done