This repository was archived by the owner on Feb 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 445
Expand file tree
/
Copy pathloc_import.sh
More file actions
executable file
·50 lines (41 loc) · 1.54 KB
/
Copy pathloc_import.sh
File metadata and controls
executable file
·50 lines (41 loc) · 1.54 KB
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
# Get the directory where the script is stored
script_dir=$(dirname "$(readlink -f "$0")")
base_dir="${script_dir}/.."
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} ..."
if ! xcodebuild -importLocalizations -project "${base_dir}/DuckDuckGo-iOS.xcodeproj" -sdk iphoneos -localizationPath "${dir}/${fileName}"; 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 "${base_dir}/DuckDuckGo/${targetLocale}.lproj/Localizable.stringsdict"
elif test -f "${dir}/${baseName}.stringsdict"; then
fileName="${baseName}.stringsdict"
echo "Processing ${locale} stringsdict"
cp "${dir}/${fileName}" "${base_dir}/DuckDuckGo/${targetLocale}.lproj/Localizable.stringsdict"
else
echo "ERROR: ${fileName} xliff or stringsdict not found in ${dir}"
echo
exit 1
fi
done

