forked from duckduckgo/iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloc_import.sh
executable file
·44 lines (35 loc) · 1.11 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
#!/bin/sh
xliffName=$2
if [ $# -ne 2 ]; then
xliffName="en.xliff"
fi
for dir in $1/*; do
echo processing $dir
locale=`basename "$dir"`
targetLocale=$(echo $locale | cut -f1 -d-)
if test -f "$dir/$xliffName"; then
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/$xliffName"
rm "$dir/$xliffName.bak"
fi
echo "Importing $dir/$xliffName ..."
xcodebuild -importLocalizations -project DuckDuckGo.xcodeproj -localizationPath "$dir/$xliffName"
if [ $? -ne 0 ]; then
echo "ERROR: Failed to import $dir/$xliffName"
echo
echo "Check translation folder and files then try again."
echo
exit 1
fi
elif test -f "$dir/Localizable.stringsdict"; then
echo "Processing $locale stringsdict"
cp "$dir/Localizable.stringsdict" "DuckDuckGo/$targetLocale.lproj/"
else
echo "ERROR: $xliffName or Localizable.stringsdict not found in $dir"
echo
exit 1
fi
done