Skip to content

Commit

Permalink
Re-enable local genstrings localisation.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuconnolly committed Oct 21, 2018
1 parent 3c56beb commit 1576d91
Showing 1 changed file with 47 additions and 47 deletions.
94 changes: 47 additions & 47 deletions Scripts/localize.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/ksh
#! /bin/ksh

#
# localize.sh
Expand Down Expand Up @@ -32,54 +32,54 @@

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

#if [ "${BUILT_PRODUCTS_DIR}x" == 'x' ]
#then
# echo 'This script should only be run by Xcode. Exiting...'
# exit 1
#fi
#
#echo "Running genstrings to update 'Localizable.strings'..."
#
if [ "${BUILT_PRODUCTS_DIR}x" == 'x' ]
then
echo 'This script should only be run by Xcode. Exiting...'
exit 1
fi

echo "Running genstrings to update 'Localizable.strings'..."

# Update 'Localizable.strings' by running genstrings(1)
#GENSTRINGS_ERRORS=$(genstrings -o "${SRCROOT}/Resources/English.lproj" "${SRCROOT}/Source/"*.m)
#
GENSTRINGS_ERRORS=$(genstrings -o "${SRCROOT}/Resources/English.lproj" "${SRCROOT}/Source/"*.m)

# Check for genstrings errors
#if [[ ${GENSTRINGS_ERRORS} -ne 0 ]]
#then
# echo "error: genstrings exited with error: ${GENSTRINGS_ERRORS}"
#fi
#
#echo "Updating nib and xib localisations..."
#
if [[ ${GENSTRINGS_ERRORS} -ne 0 ]]
then
echo "error: genstrings exited with error: ${GENSTRINGS_ERRORS}"
fi

echo "Updating nib and xib localisations..."

# Generate up-to-date nib .strings files for localisation
#find "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"/**/*.nib | while read nibFile
#do
# stringsFilePath="${SOURCE_ROOT}/Resources/English.lproj/`basename "${nibFile}" .nib`.strings"
# xibFile=`basename "${nibFile}" .nib`.xib
# xibFilePath=`echo "${SOURCE_ROOT}"/Interfaces/**/"${xibFile}"`
#
# if [[ -e ${xibFilePath} ]]
# then
# xibfileModDate=`stat -f "%m" "${xibFilePath}"`
#
# if [[ -e ${stringsFilePath} ]]
# then
# stringsFileModDate=`stat -f "%m" "${stringsFilePath}"`
# else
# stringsFileModDate=0
# fi
#
# if [[ ${xibfileModDate} -gt ${stringsFileModDate} ]]
# then
# printf "\tLocalising ${xibFile}...\n";
#
# ibtool --generate-stringsfile "${stringsFilePath}~" "${xibFilePath}"
#
# "${BUILT_PRODUCTS_DIR}"/xibLocalizationPostprocessor "${stringsFilePath}~" "${stringsFilePath}"
#
# rm "${stringsFilePath}~"
# fi
# fi
#done
find "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"/**/*.nib | while read NIB_FILE
do
STRINGS_FILE_PATH="${SOURCE_ROOT}/Resources/English.lproj/`basename "${NIB_FILE}" .nib`.strings"
XIB_FILE=`basename "${NIB_FILE}" .nib`.xib
XIB_FILE_PATH=`echo "${SOURCE_ROOT}"/Interfaces/**/"${XIB_FILE}"`

if [[ -e ${XIB_FILE_PATH} ]]
then
XIB_FILE_MOD_DATE=`stat -f "%m" "${XIB_FILE_PATH}"`

if [[ -e ${STRINGS_FILE_PATH} ]]
then
STRINGS_FILE_MOD_DATE=`stat -f "%m" "${STRINGS_FILE_PATH}"`
else
STRINGS_FILE_MOD_DATE=0
fi

if [[ ${XIB_FILE_MOD_DATE} -gt ${STRINGS_FILE_MOD_DATE} ]]
then
printf "\tLocalising ${XIB_FILE}...\n";

ibtool --generate-stringsfile "${STRINGS_FILE_PATH}~" "${XIB_FILE_PATH}"

"${BUILT_PRODUCTS_DIR}"/xibLocalizationPostprocessor "${STRINGS_FILE_PATH}~" "${STRINGS_FILE_PATH}"

rm "${STRINGS_FILE_PATH}~"
fi
fi
done

exit 0

0 comments on commit 1576d91

Please sign in to comment.