Source

growl / Tools / update_growl_from_bundle

Full commit
#!/bin/sh
###############
#
# Usage: update_growl_from_bundle SOURCE_BUNDLE_PATH LANGUAGE_NAME
#        for example:
#            ~/bin/update_growl_from_bundle Desktop/Growl_French.prefPane French
#
# if LANGUAGE_NAME is "all", all languages will be updated. Note that the
# languages are specified at the bottom of this file.
#
# Set REPO to your Growl repository
#
# To add a new language, the language should first be added in XCode and
# added to the repository with svn add. Then, run the script to copy in
# the localizations.
#
# This script does not cover Growl-WithInstaller.framework or Growl Extras.
################
REPO=~/growl

SOURCE=$1

########
# Functions
########

# Update a nib. First argument is the name of the nib,
# with the .nib extension. Second argument is the destination folder.
# The nib must already exist in the destination.
update_nib()
{
    for file in $1/*.nib ; do
        cp $file $2/$1
    done
}

# Copy all nibs and other files in the current directory to a given destination
loc_copy()
{
    find . '(' -name "*.nib" ')' -prune -execdir cp "{}/classes.nib" "$1/{}" ';'
    find . '(' -name "*.nib" ')' -prune -execdir cp "{}/keyedobjects.nib" "$1/{}" ';'
    find . '(' -name "*.nib" ')' -prune -execdir cp "{}/objects.xib" "$1/{}" ';'

    for file in * ; do
        if [ -f  $file ] ; then
            cp $file $1
        fi
    done
}

silent_pushd()
{
    pushd "$1" >/dev/null
}

silent_popd()
{
    popd >/dev/null
}

#####
# Begin!
#####

update_language()
{
    #first parameter to update_language is the language
    LANG=$1.lproj
    
    echo "+++++ Updating $LANG"

    silent_pushd "$SOURCE/Contents/Resources"
    
    # Main resources (PrefPane)
    silent_pushd $LANG
        loc_copy "$REPO/Core/Resources/$LANG"
        rm "$REPO/Core/Resources/$LANG/WebKitPrefs.nib"
        update_nib WebKitPrefs.nib "$REPO/Plugins/Displays/WebKit/$LANG"
    silent_popd
    
    # Growl Helper App (which includes all the display plugins)
    silent_pushd GrowlHelperApp.app/Contents
        echo "**** Updating Growl Helper App"
        silent_pushd Resources/$LANG
            #GHA's localizable.strings goes to the same place as the prefpanne's
            cp Localizable.strings "$REPO/Core/Resources/$LANG"
        silent_popd
    
        # Plugins
        echo "**** Updating Display Plugins"
        silent_pushd PlugIns
        for plugin in *.growlView ; do
            silent_pushd $plugin/Contents/Resources/$LANG
                PLUGIN_NAME=`echo $plugin | cut -f1 -d .`
                echo "**** Updating Display Plugin $PLUGIN_NAME"
                loc_copy "$REPO/Plugins/Displays/$PLUGIN_NAME/$LANG"
            silent_popd
        done
        silent_popd
    silent_popd
    
    # GrowlMenu
    echo "**** Updating GrowlMenu"
    silent_pushd GrowlMenu.app/Contents/Resources/$LANG
        loc_copy "$REPO/StatusItem/Resources/$LANG"
    silent_popd
    
    silent_popd
}

if [ "$2" = "all" ]  ; then
    for lang in \
        cs \
        Dutch \
        French \
        German \
        Japanese \
        pt_BR \
        Russian \
        Swedish \
        zh_CN \
        zh_TW \
        ; do
            update_language $lang
    done
else
    update_language $2
fi