Skip to content

Instantly share code, notes, and snippets.

@trilliwon
Last active January 11, 2022 08:03
Show Gist options
  • Save trilliwon/dec9c07e0f18da2c0f143c96f3d0b2ea to your computer and use it in GitHub Desktop.
Save trilliwon/dec9c07e0f18da2c0f143c96f3d0b2ea to your computer and use it in GitHub Desktop.
makeI18N
#!/bin/sh
echo "generating I18N.swift"
touch tempI18N.swift
echo "struct I18N {" >> tempI18N.swift
inputfile=${SRCROOT}/Pomodoro/Resources/en.lproj/Localizable.strings
while IFS= read -r line
do
echo $line
pattern='^[a-zA-Z]+(.*)[\\s]*=[\\s]*(.*)$'
comment='\/\/.+'
if [[ $line =~ $pattern ]]
then
echo "Yes👌"
variableName=$(echo ${line%%=*})
echo $variableName
if [ "$variableName" != "" ]; then
echo " static let $variableName = \"$variableName\".localized" >> tempI18N.swift
fi
else
if [[ $line =~ $comment ]]
then
echo "Comment 📝"
echo "\n $line" >> tempI18N.swift
else
echo "No👎"
fi
fi
done <"$inputfile"
echo "}" >> tempI18N.swift
cat tempI18N.swift > ${SRCROOT}/Pomodoro/Resources/I18N.swift
rm tempI18N.swift
echo "-------------"
cat $inputfile
cat ${SRCROOT}/Manhwakyung-ios/Resources/I18N.swift
echo "-------------"