Skip to content

Commit 1576d91

Browse files
committed
Re-enable local genstrings localisation.
1 parent 3c56beb commit 1576d91

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

Scripts/localize.sh

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /bin/ksh
1+
#! /bin/ksh
22

33
#
44
# localize.sh
@@ -32,54 +32,54 @@
3232

3333
# Localizes all of the application's NIB files. This script should only be run by Xcode.
3434

35-
#if [ "${BUILT_PRODUCTS_DIR}x" == 'x' ]
36-
#then
37-
# echo 'This script should only be run by Xcode. Exiting...'
38-
# exit 1
39-
#fi
40-
#
41-
#echo "Running genstrings to update 'Localizable.strings'..."
42-
#
35+
if [ "${BUILT_PRODUCTS_DIR}x" == 'x' ]
36+
then
37+
echo 'This script should only be run by Xcode. Exiting...'
38+
exit 1
39+
fi
40+
41+
echo "Running genstrings to update 'Localizable.strings'..."
42+
4343
# Update 'Localizable.strings' by running genstrings(1)
44-
#GENSTRINGS_ERRORS=$(genstrings -o "${SRCROOT}/Resources/English.lproj" "${SRCROOT}/Source/"*.m)
45-
#
44+
GENSTRINGS_ERRORS=$(genstrings -o "${SRCROOT}/Resources/English.lproj" "${SRCROOT}/Source/"*.m)
45+
4646
# Check for genstrings errors
47-
#if [[ ${GENSTRINGS_ERRORS} -ne 0 ]]
48-
#then
49-
# echo "error: genstrings exited with error: ${GENSTRINGS_ERRORS}"
50-
#fi
51-
#
52-
#echo "Updating nib and xib localisations..."
53-
#
47+
if [[ ${GENSTRINGS_ERRORS} -ne 0 ]]
48+
then
49+
echo "error: genstrings exited with error: ${GENSTRINGS_ERRORS}"
50+
fi
51+
52+
echo "Updating nib and xib localisations..."
53+
5454
# Generate up-to-date nib .strings files for localisation
55-
#find "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"/**/*.nib | while read nibFile
56-
#do
57-
# stringsFilePath="${SOURCE_ROOT}/Resources/English.lproj/`basename "${nibFile}" .nib`.strings"
58-
# xibFile=`basename "${nibFile}" .nib`.xib
59-
# xibFilePath=`echo "${SOURCE_ROOT}"/Interfaces/**/"${xibFile}"`
60-
#
61-
# if [[ -e ${xibFilePath} ]]
62-
# then
63-
# xibfileModDate=`stat -f "%m" "${xibFilePath}"`
64-
#
65-
# if [[ -e ${stringsFilePath} ]]
66-
# then
67-
# stringsFileModDate=`stat -f "%m" "${stringsFilePath}"`
68-
# else
69-
# stringsFileModDate=0
70-
# fi
71-
#
72-
# if [[ ${xibfileModDate} -gt ${stringsFileModDate} ]]
73-
# then
74-
# printf "\tLocalising ${xibFile}...\n";
75-
#
76-
# ibtool --generate-stringsfile "${stringsFilePath}~" "${xibFilePath}"
77-
#
78-
# "${BUILT_PRODUCTS_DIR}"/xibLocalizationPostprocessor "${stringsFilePath}~" "${stringsFilePath}"
79-
#
80-
# rm "${stringsFilePath}~"
81-
# fi
82-
# fi
83-
#done
55+
find "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"/**/*.nib | while read NIB_FILE
56+
do
57+
STRINGS_FILE_PATH="${SOURCE_ROOT}/Resources/English.lproj/`basename "${NIB_FILE}" .nib`.strings"
58+
XIB_FILE=`basename "${NIB_FILE}" .nib`.xib
59+
XIB_FILE_PATH=`echo "${SOURCE_ROOT}"/Interfaces/**/"${XIB_FILE}"`
60+
61+
if [[ -e ${XIB_FILE_PATH} ]]
62+
then
63+
XIB_FILE_MOD_DATE=`stat -f "%m" "${XIB_FILE_PATH}"`
64+
65+
if [[ -e ${STRINGS_FILE_PATH} ]]
66+
then
67+
STRINGS_FILE_MOD_DATE=`stat -f "%m" "${STRINGS_FILE_PATH}"`
68+
else
69+
STRINGS_FILE_MOD_DATE=0
70+
fi
71+
72+
if [[ ${XIB_FILE_MOD_DATE} -gt ${STRINGS_FILE_MOD_DATE} ]]
73+
then
74+
printf "\tLocalising ${XIB_FILE}...\n";
75+
76+
ibtool --generate-stringsfile "${STRINGS_FILE_PATH}~" "${XIB_FILE_PATH}"
77+
78+
"${BUILT_PRODUCTS_DIR}"/xibLocalizationPostprocessor "${STRINGS_FILE_PATH}~" "${STRINGS_FILE_PATH}"
79+
80+
rm "${STRINGS_FILE_PATH}~"
81+
fi
82+
fi
83+
done
8484

8585
exit 0

0 commit comments

Comments
 (0)