Blame Scripts/Bash/Functions/Render/render_getIdentityDefs.sh

4c79b5
#!/bin/bash
4c79b5
#
4c79b5
# render_getIdentityDefs.sh -- This function provides shared variables
5276a6
# re-definitions for all rendition actions inside centos-art.sh
5276a6
# script.
4c79b5
#
9f5f2e
# Copyright (C) 2009-2011 Alain Reguera Delgado
4c79b5
# 
7cd8e9
# This program is free software; you can redistribute it and/or
7cd8e9
# modify it under the terms of the GNU General Public License as
7cd8e9
# published by the Free Software Foundation; either version 2 of the
7cd8e9
# License, or (at your option) any later version.
4c79b5
# 
4c79b5
# This program is distributed in the hope that it will be useful, but
4c79b5
# WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
4c79b5
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
4c79b5
# USA.
4c79b5
# 
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
4c79b5
function render_getIdentityDefs {
4c79b5
5276a6
    # Define final location of translation file.
5276a6
    TRANSLATION=$(dirname $FILE \
5276a6
        | sed -r 's!/trunk/(Identity/)!/trunk/Locales/\1!')/$(cli_getCurrentLocale).po
4c79b5
5276a6
    # Print final location of translation file.
5276a6
    if [[ ! -f "$TRANSLATION" ]];then
4c79b5
        cli_printMessage "`gettext "None"`" "AsTranslationLine"
4c79b5
    else
5187da
        cli_printMessage "$TRANSLATION" 'AsTranslationLine'
4c79b5
    fi
4c79b5
5276a6
    # Define final location of template file.
5276a6
    TEMPLATE=${FILE}
9b4d7d
5276a6
    # Print final location of template file.
5276a6
    if [[ ! -f "$TEMPLATE" ]];then
5276a6
        cli_printMessage "`gettext "None"`" "AsDesignLine"
4c79b5
    else
5276a6
        cli_printMessage "$TEMPLATE" 'AsDesignLine'
4c79b5
    fi
5276a6
 
5276a6
    # Define final location of output directory.
5276a6
    render_getIdentityDirOutput
9b4d7d
4c79b5
    # Get relative path to file. The path string (stored in FILE) has
4c79b5
    # two parts: 1. the variable path and 2. the common path.  The
4c79b5
    # variable path is before the common point in the path string. The
4c79b5
    # common path is after the common point in the path string. The
4c79b5
    # common point is the name of the parent directory (stored in
4c79b5
    # PARENTDIR).
4c79b5
    #
5276a6
    # trunk/Locales/Identity/.../Firstboot/3/splash-small.svg
4c79b5
    # -------------------------^| the     |^------------^
4c79b5
    # variable path             | common  |    common path
4c79b5
    # -------------------------v| point   |    v------------v
ecc4c5
    # trunk/Identity/Themes/M.../Firstboot/Img/3/splash-small.png
4c79b5
    #
4c79b5
    # What we do here is remove the varibale path, the common point,
4c79b5
    # and the file extension parts in the string holding the path
5276a6
    # retrived from design models directory structure. Then we use the
5276a6
    # common path as relative path to store the the final image file.
4c79b5
    #
5276a6
    # The file extension is removed from the common path because it is
5276a6
    # set when we create the final image file. This configuration let
5276a6
    # us use different extensions for the same file name.
4c79b5
    #
15b1d2
    # When we render using renderImage function, the structure of
5276a6
    # files under the output directory will be the same used after the
5276a6
    # common point in the related design model directory structure.
9b4d7d
    FILE=$(echo ${FILE} \
4c79b5
        | sed -r "s!.*${PARENTDIR}/!!" \
5276a6
        | sed -r "s/\.(svgz|svg)$//")
189dda
5276a6
    # Define absolute path to final file (without extension).
5276a6
    FILE=${OUTPUT}/$(basename "${FILE}")
189dda
5276a6
    # Define instance name from design model.
5276a6
    INSTANCE=$(cli_getTemporalFile ${TEMPLATE})
076a85
5276a6
    if [[ -f ${TRANSLATION} ]];then
5276a6
        # Create translated instance from design model.
5276a6
        /usr/bin/xml2po -p ${TRANSLATION} -o ${INSTANCE} ${TEMPLATE}
5276a6
    else
5276a6
        # Create non-translated instance form design model.
5276a6
        /bin/cat ${TEMPLATE} > ${INSTANCE}    
4c79b5
    fi
4c79b5
5276a6
    # Apply replacement of translation markers to design model
5276a6
    # translated instance.
5276a6
    cli_replaceTMarkers ${INSTANCE}
7ac81d
4c79b5
}