Blame Scripts/Functions/Locale/locale.sh

4c79b5
#!/bin/bash
4c79b5
#
957ef9
# locale.sh -- This function provides internationalization features
80bc6f
# for centos-art.sh script through GNU gettext standard processes.
4c79b5
#
3b0984
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
fa95b1
#
fa95b1
# This program is free software; you can redistribute it and/or modify
fa95b1
# it under the terms of the GNU General Public License as published by
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
fa95b1
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# 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
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
7ac5a5
#
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
4c79b5
function locale {
4c79b5
f1a655
    # Do not locale messages for English language. The English
f1a655
    # language is already used as translation pattern and there is no
f1a655
    # translation messages for it.
f1a655
    if [[ $(cli_getCurrentLocale) =~ '^en' ]];then
510fad
        cli_printMessage "`gettext "Cannot locale English language to itself."`" --as-error-line
f1a655
    fi
f1a655
80bc6f
    local ACTIONNAMS=''
73abe0
    local ACTIONNAM=''
73abe0
    local ACTIONVAL=''
73abe0
2b3016
    # Initialize default value to create/update machine object flag.
bf6bff
    # The machine object flag (--dont-create-mo) controls whether
bf6bff
    # centos-art.sh script does create/update the machine object
bf6bff
    # related object or not.
0d4faa
    local FLAG_DONT_CREATE_MO='false'
2b3016
80bc6f
    # Define localization (l10n) base directory. This is the place
34cd8d
    # where all translation messages are organized in. Translation
80bc6f
    # messages, here, are organized using the same organization of the
34cd8d
    # components they represent inside the `trunk/Identity',
34cd8d
    # `trunk/Manuals' or `trunk/Scripts' directory structures.
80bc6f
    # The localization base directory must be used as source location
80bc6f
    # for subverion operations (e.g., status, update, commit, etc.).
80bc6f
    # Otherwise, it would be difficult to add directory structures
80bc6f
    # that have several levels down from the localization base
80bc6f
    # directory up to the repository (e.g., it is not possible in
34cd8d
    # subversion to add a directory structure which parent directory
34cd8d
    # structure hasn't been added to the repository, previously.).
a5d502
    L10N_BASEDIR="$(cli_getRepoTLDir)/L10n"
34cd8d
73abe0
    # Interpret arguments and options passed through command-line.
80bc6f
    ${FUNCNAM}_getOptions
73abe0
73abe0
    # Redefine positional parameters using ARGUMENTS. At this point,
73abe0
    # option arguments have been removed from ARGUMENTS variable and
73abe0
    # only non-option arguments remain in it. 
73abe0
    eval set -- "$ARGUMENTS"
73abe0
34cd8d
    # Syncronize changes between repository and working copy. At this
34cd8d
    # point, changes in the repository are merged in the working copy
34cd8d
    # and changes in the working copy committed up to repository.
34cd8d
    cli_syncroRepoChanges "${L10N_BASEDIR}"
34cd8d
73abe0
    # Define action value. As convenction, we use non-option arguments
73abe0
    # to define the action value (ACTIONVAL) variable.
73abe0
    for ACTIONVAL in "$@";do
73abe0
73abe0
        # Check action value. Be sure the action value matches the
73abe0
        # convenctions defined for source locations inside the working
73abe0
        # copy.
dc2f3c
        ACTIONVAL=$(cli_checkRepoDirSource $ACTIONVAL)
73abe0
c3e209
        # Verify whether the directory provided can have localization
c3e209
        # messages or not.
99fa4a
        if [[ ! $(cli_isLocalized $ACTIONVAL) == 'true' ]];then
c3e209
            cli_printMessage "`gettext "The path provided doesn't support localization."`" --as-error-line
c3e209
        fi
c3e209
80bc6f
        # Define localization working directory. This is the place
80bc6f
        # where language-specific directories are stored in.
ed2bf0
        WORKDIR=$(echo ${ACTIONVAL} \
a5d502
            | sed -r -e "s!trunk/(Identity|Scripts|Manuals)!trunk/L10n/\1!")
ed2bf0
80bc6f
        # Redefine localization working directory to include
80bc6f
        # language-specific directories. This is the place where POT,
80bc6f
        # PO, and MO files are stored in.
ed2bf0
        WORKDIR=$WORKDIR/$(cli_getCurrentLocale)
ed2bf0
80bc6f
        # Execute action names.
80bc6f
        for ACTIONNAM in $ACTIONNAMS;do
80bc6f
            ${ACTIONNAM}
80bc6f
        done
73abe0
73abe0
    done
4c79b5
3906a2
    # Syncronize changes between repository and working copy. At this
3906a2
    # point, changes in the repository are merged in the working copy
3906a2
    # and changes in the working copy committed up to repository.
3906a2
    cli_syncroRepoChanges "${L10N_BASEDIR}"
34cd8d
4c79b5
}