Skip to content

Instantly share code, notes, and snippets.

@mamarx
Created March 17, 2015 12:21
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mamarx/9f4464dd8b2c95139aad to your computer and use it in GitHub Desktop.
Save mamarx/9f4464dd8b2c95139aad to your computer and use it in GitHub Desktop.
#!/bin/sh
# UpdateTranslations.sh
#
# Created by Malte Marx on 13.08.14.
# Copyright (c) 2014 marxbeck GmbH. All rights reserved.
localizationsPath="Resources/Localizations"
controllersPath="Controllers"
languages=(de en es fr)
storyboards=(Controller1 Controller2 Controller3)
# For each storyboard
for storyboard in ${storyboards[@]} ; do
# Push english translation file
phrase push ${controllersPath}/${storyboard}/en.lproj/${storyboard}.strings --locale=en --tags=${storyboard}
# Pull language translations and clean and rename folders for each language
for language in ${languages[@]} ; do
# Pull translation files into storyboard folder
phrase pull ${language} --target=${controllersPath}/${storyboard}/ --format=strings --tag=${storyboard}
# Clean and rename
if [ -f ${controllersPath}/${storyboard}/${language}.lproj/Localizable.strings ] ; then
rm -f ${controllersPath}/${storyboard}/${language}.lproj/${storyboard}.strings
mv ${controllersPath}/${storyboard}/${language}.lproj/Localizable.strings ${controllersPath}/${storyboard}/${language}.lproj/${storyboard}.strings
fi
done
done
# Generate new entries in Base locale for new translation keys
find ./ -name "*.m" -print0 | xargs -0 genstrings -o ${localizationsPath}/Base.lproj
# Push to PhraseApp
phrase push ${localizationsPath}/Base.lproj/Localizable.strings --locale=Base --tags=Localizable
phrase push ${localizationsPath}/Base.lproj/InfoPlist.strings --locale=Base --tags=InfoPlist
# Pull from PhraseApp
phrase pull --target=${localizationsPath} --format=strings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment