Blame Automation/Modules/Locale/locale_updateMessages.sh

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# locale_updateMessages.sh -- This function extracts translatable
Alain Reguera Delgado 8f60cb
# strings from both XML-based files (using xml2po) and shell scripts
Alain Reguera Delgado 8f60cb
# (using xgettext). Translatable strings are initially stored in
Alain Reguera Delgado 8f60cb
# portable objects templates (.pot) which are later merged into
Alain Reguera Delgado 8f60cb
# portable objects (.po) in order to be optionally converted as
Alain Reguera Delgado 8f60cb
# machine objects (.mo).
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# Copyright (C) 2009-2013 The CentOS Project
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# This program is free software; you can redistribute it and/or modify
Alain Reguera Delgado 8f60cb
# it under the terms of the GNU General Public License as published by
Alain Reguera Delgado 8f60cb
# the Free Software Foundation; either version 2 of the License, or (at
Alain Reguera Delgado 8f60cb
# your option) any later version.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# This program is distributed in the hope that it will be useful, but
Alain Reguera Delgado 8f60cb
# WITHOUT ANY WARRANTY; without even the implied warranty of
Alain Reguera Delgado 8f60cb
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Alain Reguera Delgado 8f60cb
# General Public License for more details.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# You should have received a copy of the GNU General Public License
Alain Reguera Delgado 8f60cb
# along with this program; if not, write to the Free Software
Alain Reguera Delgado 8f60cb
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# ----------------------------------------------------------------------
Alain Reguera Delgado 8f60cb
# $Id$
Alain Reguera Delgado 8f60cb
# ----------------------------------------------------------------------
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
function locale_updateMessages {
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Verify directory passed as non-option argument to be sure it
Alain Reguera Delgado 8f60cb
    # supports localization.
Alain Reguera Delgado 8f60cb
    locale_isLocalizable "${ACTIONVAL}"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Prepare working directory to receive translation files.  Don't
Alain Reguera Delgado 8f60cb
    # do this here. This location can be redefine later based on
Alain Reguera Delgado 8f60cb
    # deeper directory structures not provided as arguments to
Alain Reguera Delgado 8f60cb
    # centos-art.sh script. For example, if you execute the following
Alain Reguera Delgado 8f60cb
    # command:
Alain Reguera Delgado 8f60cb
    #
Alain Reguera Delgado 8f60cb
    #   centos-art locale Documentation/Models/Svg/Brands --update
Alain Reguera Delgado 8f60cb
    #
Alain Reguera Delgado 8f60cb
    # it should produce the following directory structure:
Alain Reguera Delgado 8f60cb
    #
Alain Reguera Delgado 8f60cb
    #   Locales/Documentation/Models/Svg/Brands/Logos/${LANG}/
Alain Reguera Delgado 8f60cb
    #   Locales/Documentation/Models/Svg/Brands/Symbols/${LANG}/
Alain Reguera Delgado 8f60cb
    #   Locales/Documentation/Models/Svg/Brands/Types/${LANG}/
Alain Reguera Delgado 8f60cb
    #
Alain Reguera Delgado 8f60cb
    # and not the next one:
Alain Reguera Delgado 8f60cb
    #
Alain Reguera Delgado 8f60cb
    #   Locales/Documentation/Models/Svg/Brands/${LANG}/
Alain Reguera Delgado 8f60cb
    #
Alain Reguera Delgado 8f60cb
    # So, don't prepare working directory to receive translation files
Alain Reguera Delgado 8f60cb
    # here. Instead, do it just before POT files creation.
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Evaluate action value to determine whether to use xml2po to
Alain Reguera Delgado 8f60cb
    # extract translatable strings from XML-based files or to use
Alain Reguera Delgado 8f60cb
    # xgettext to extract translatable strings from shell script
Alain Reguera Delgado 8f60cb
    # files.
Alain Reguera Delgado 8f60cb
    if [[ $ACTIONVAL =~ "^${TCAR_WORKDIR}/(Documentation/Models/(Docbook|Svg)|Identity/Models)/.*$" ]];then
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Update translatable strings inside the portable object
Alain Reguera Delgado 8f60cb
        # template related to XML-based files (e.g., scalable vector
Alain Reguera Delgado 8f60cb
        # graphics).
Alain Reguera Delgado 8f60cb
        locale_updateMessageXml
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    elif [[ $ACTIONVAL =~ "^${TCAR_WORKDIR}/Scripts/Bash$" ]];then
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Update translatable strings inside the portable object
Alain Reguera Delgado 8f60cb
        # template related to shell scripts (e.g., the centos-art.sh
Alain Reguera Delgado 8f60cb
        # script).
Alain Reguera Delgado 8f60cb
        locale_updateMessageShell
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    else
Alain Reguera Delgado 8f60cb
        cli_printMessage "`gettext "The path provided doesn't support localization."`" --as-error-line
Alain Reguera Delgado 8f60cb
    fi
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
}