Blame Scripts/Bash/Functions/Manual/manual_createLanguageLayout.sh

4c79b5
#!/bin/bash
4c79b5
#
4de5d4
# manual_createLanguageLayout.sh -- This function creates texinfo's main
4c79b5
# documentation structure for an specific language.
4c79b5
#
72c8a5
# 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
# ----------------------------------------------------------------------
4c79b5
4de5d4
function manual_createLanguageLayout {
4c79b5
4c79b5
    # Define variables as local to avoid conflicts outside
4c79b5
    local COUNTER=0
4c79b5
    local MESSAGE=''
4c79b5
4c79b5
    # Initialize translation markers for texinfo manual template.
4c79b5
    local DOCTPL[0]="`gettext "Set the document's title"`"
4c79b5
    local DOCTPL[1]="`gettext "Set the document's subtitle"`"
4c79b5
    local DOCTPL[2]="`gettext "Set the document's description"`"
4c79b5
    local DOCTPL[3]="`gettext "Set the document's author"`"
4c79b5
4c79b5
    # Request texinfo document initial information. Since the main
4c79b5
    # texinfo documentation file (repository.texi) requires language
4c79b5
    # specific values (e.g., document title, subtitle, description,
4c79b5
    # author, etc.) before they can be used, there is no way to create
4c79b5
    # those files automatically without requesting the user for those
4c79b5
    # initial information on his/her own language. The requesting
4c79b5
    # process is done in English language.
4c79b5
    for MESSAGE in "${DOCTPL[@]}";do
4c79b5
        cli_printMessage "`gettext "Step"` ${COUNTER}: $MESSAGE:" "AsRequestLine"
4c79b5
        read DOCTPL[${COUNTER}]
4c79b5
        if [[ ! $DOCTPL[${COUNTER}] =~ '[[:print:]]+' ]];then
4c79b5
            cli_printMessage "`gettext "The string entered isn't valid."`"
1f1b3c
            cli_printMessage "$(caller)" "AsToKnowMoreLine"
4c79b5
        fi
4c79b5
        COUNTER=$(($COUNTER + 1))
4c79b5
    done
4c79b5
    
4c79b5
    # At this point all information required to build texinfo document
4c79b5
    # has been collected. Leave a message and start creating texinfo
4c79b5
    # files based on template.
4c79b5
    local LANGNAME=$(cli_getLangName $(cli_getCurrentLocale))
4c79b5
4c79b5
    # Create language directory to store texinfo document structure.
4c79b5
    if [[ ! -d ${MANUALS_DIR[2]} ]];then
4c79b5
        mkdir -p ${MANUALS_DIR[2]}
4c79b5
    fi
4c79b5
4c79b5
    # Fill texinfo template with entered values and store the result
4c79b5
    # as new texinfo document structure.
4c79b5
    cat ${MANUALS_DIR[6]}/repository.texi \
4c79b5
        | sed -r "s!=TITLE=!${DOCTPL[0]}!g" \
4c79b5
        | sed -r "s!=SUBTITLE=!${DOCTPL[1]}!g" \
4c79b5
        | sed -r "s!=DESCRIPTION=!${DOCTPL[2]}!g" \
4c79b5
        | sed -r "s!=AUTHOR=!${DOCTPL[3]}!g" \
4c79b5
        | sed -r "s!=LANGUAGE=!$(cli_getLangCodes $(cli_getCurrentLocale))!g" \
4c79b5
        > ${MANUALS_DIR[2]}/repository.texi
4c79b5
4c79b5
    # Copy menu and nodes from template to texinfo document structure.
4c79b5
    cp ${MANUALS_DIR[6]}/$(basename ${MANUALS_FILE[2]}) ${MANUALS_DIR[2]}/
4c79b5
    cp ${MANUALS_DIR[6]}/$(basename ${MANUALS_FILE[3]}) ${MANUALS_DIR[2]}/
4c79b5
    cp ${MANUALS_DIR[6]}/$(basename ${MANUALS_FILE[11]}) ${MANUALS_DIR[2]}/
4c79b5
4c79b5
    # Translate English words. As we are creating texinfo
4c79b5
    # documentation from an English template, it is needed to
4c79b5
    # translate some words from English to the current language we are
4c79b5
    # creating texinfo documentation for.
4c79b5
    sed -r -i "s!Index!`gettext "Index"`!" ${MANUALS_FILE[11]} ${MANUALS_FILE[2]}
4c79b5
4c79b5
    # Output action message.
4c79b5
    cli_printMessage "`eval_gettext "The \\\"\\\$LANGNAME\\\" documentation structure has been created."`"
4c79b5
4c79b5
}