diff --git a/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Sh/sh.sh b/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Sh/sh.sh index 0e2691c..a7d3477 100755 --- a/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Sh/sh.sh +++ b/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Sh/sh.sh @@ -30,11 +30,21 @@ function sh { # Print action message. tcar_printMessage "${POT_FILE}" --as-updating-line + # Define package name. This is the name of the initialization file + # you provided as argument to the command line to provide + # localization for. + local PACKAGE_NAME=${FILE_NAME} + + # Define package version. The script version is used here. Modules + # doesn't have a version by now. They share the same version of + # the centos-art.sh script. + local PACKAGE_VERSION=${TCAR_SCRIPT_VERSION} + # Retrieve translatable strings from shell script files and create # the portable object template (.pot) from them. xgettext --output=${POT_FILE} --width=70 \ - --package-name=${TCAR_SCRIPT_NAME} \ - --package-version=${TCAR_SCRIPT_VERSION} \ + --package-name=${PACKAGE_NAME} \ + --package-version=${PACKAGE_VERSION} \ --msgid-bugs-address="centos-l10n-${TCAR_SCRIPT_LANG_LL}@centos.org.cu" \ --copyright-holder="$(tcar_printCopyrightInfo --holder)" \ --sort-by-file ${SOURCES[*]} diff --git a/Automation/Modules/Locale/Modules/Actions/Modules/Update/update_setPoMetadata.sh b/Automation/Modules/Locale/Modules/Actions/Modules/Update/update_setPoMetadata.sh index d8b6764..438e8d8 100755 --- a/Automation/Modules/Locale/Modules/Actions/Modules/Update/update_setPoMetadata.sh +++ b/Automation/Modules/Locale/Modules/Actions/Modules/Update/update_setPoMetadata.sh @@ -49,7 +49,7 @@ function update_setPoMetadata { SRC[3]="\"PO-Revision-Date: (.+)?" # Define replacement lines for pattern line. - DST[0]="\"Project-Id-Version: ${TCAR_SCRIPT_NAME} ${TCAR_SCRIPT_VERSION}\\\n\"" + DST[0]="\"Project-Id-Version: ${PACKAGE_NAME} ${PACKAGE_VERSION}\\\n\"" DST[1]="\"Last-Translator: Localization SIG \\\n\"" DST[2]="\"Language-Team: $(update_getLanguageName)\\\n\"" DST[3]="\"PO-Revision-Date: $(date "+%F %H:%M%z")\\\n\"" @@ -61,7 +61,9 @@ function update_setPoMetadata { done # Replace package information using gettext domain information. - sed -i -r "s/PACKAGE/${TCAR_SCRIPT_NAME}-${TCAR_SCRIPT_VERSION}/g" ${PO_FILE} + # Don't include version here to prevent old version to be shown in + # the comment area when new versions of the package are created. + sed -i -r "s/PACKAGE/${PACKAGE_NAME}/g" ${PO_FILE} # Remove absolute path to the working copy so it doesn't appear on # comments related to locations. Remember that people can download diff --git a/Automation/Modules/Locale/Modules/File/file.sh b/Automation/Modules/Locale/Modules/File/file.sh index a98ff81..f1d5eed 100755 --- a/Automation/Modules/Locale/Modules/File/file.sh +++ b/Automation/Modules/Locale/Modules/File/file.sh @@ -44,12 +44,14 @@ function file { local DIRECTORY=$(dirname ${FILE}) # Define list of files to process. - local RENDER_FROM=$(tcar_getFilesList ${DIRECTORY} \ - --pattern="^.+/.+\.${FILE_EXTENSION}$" --type="f") + local RENDER_FROM=$(locale_getFilesList) # Define absolute path to directory holding language-specific # content. local LOCALE_FROM=${DIRECTORY}/Locales + if [[ ! -d ${LOCALE_FROM} ]];then + mkdir ${LOCALE_FROM} + fi # Define absolute path to portable and machine objects. local POT_FILE=${LOCALE_FROM}/${FILE_NAME}.pot diff --git a/Automation/Modules/Locale/locale.sh b/Automation/Modules/Locale/locale.sh index 8bbc85b..ddf4d91 100755 --- a/Automation/Modules/Locale/locale.sh +++ b/Automation/Modules/Locale/locale.sh @@ -29,6 +29,12 @@ function locale { local ACTIONS='' + # Define the type of file processing the locale module will do. + # The locale module can perform process just one file (self), all + # the siblings files in the current location (siblings) only, or + # all files in the current location recursively (all). + local LOCALE_FLAG_TYPE='self' + # Interpret arguments and options passed through command-line. locale_getOptions @@ -36,8 +42,8 @@ function locale { # from being localized to themselves. The English language is used # as reference to write translatable strings inside the source # files. - if [[ ${TCAR_SCRIPT_LANG_LC} =~ '^en' ]];then - tcar_printMessage "`gettext "The English language cannot be localized to itself."`" --as-error-line + if [[ ${TCAR_SCRIPT_LANG_LC} =~ '^C$' ]];then + tcar_printMessage "`gettext "The C locale cannot be localized to itself."`" --as-error-line fi # Process arguments passed to locale module, based on whether they diff --git a/Automation/Modules/Locale/locale_getFilesList.sh b/Automation/Modules/Locale/locale_getFilesList.sh new file mode 100755 index 0000000..62016c1 --- /dev/null +++ b/Automation/Modules/Locale/locale_getFilesList.sh @@ -0,0 +1,56 @@ +#!/bin/bash +###################################################################### +# +# locale_getFilesList.sh -- This function prints to standard output +# the list of files that locale module will use for processing. The +# list of files is conditioned by the LOCALE_FLAG_TYPE variable to +# determine whether the processing is applied to one file, all files +# in a directory only or all files in a directory recursively. By +# default one file processing is performed. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +###################################################################### + +function locale_getFilesList { + + case ${LOCALE_FLAG_TYPE} in + + 'all' ) + # Process all files in the current location recursively. + tcar_getFilesList ${DIRECTORY} --type="f" \ + --pattern="^.+/.+\.${FILE_EXTENSION}$" + ;; + + 'siblings' ) + # Process all files in the current location only. + tcar_getFilesList ${DIRECTORY} --maxdepth=1 --mindepth=1 \ + --type="f" --pattern="^.+/.+\.${FILE_EXTENSION}$" + ;; + + 'self' | * ) + # Process the file provided only. + tcar_getFilesList ${DIRECTORY} --maxdepth=1 --mindepth=1 \ + --type="f" --pattern="^.+/${FILE_NAME}$" + ;; + + esac + +} diff --git a/Automation/Modules/Locale/locale_getOptions.sh b/Automation/Modules/Locale/locale_getOptions.sh index 585e8d4..0da249d 100755 --- a/Automation/Modules/Locale/locale_getOptions.sh +++ b/Automation/Modules/Locale/locale_getOptions.sh @@ -28,10 +28,10 @@ function locale_getOptions { # Define short options we want to support. - local ARGSS="h::,v,f:" + local ARGSS="h::,v,f:,t:" # Define long options we want to support. - local ARGSL="help::,version,filter:,update,edit,delete" + local ARGSL="help::,version,filter:,update,edit,delete,type:" # Redefine arguments using getopt(1) command parser. tcar_setModuleArguments @@ -72,6 +72,13 @@ function locale_getOptions { shift 1 ;; + -t | --type ) + LOCALE_FLAG_TYPE="${2:-self}" + tcar_checkFiles -m '^(self|siblings|all)$' "${LOCALE_FLAG_TYPE}" + shift 2 + ;; + + -- ) shift 1 break