From 9eee8ed56f34b05927b18a0abb9ae75022e1d4d6 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Sep 06 2013 00:54:23 +0000 Subject: Update locale module's file names. --- diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc.sh b/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc.sh index 793dc16..c377994 100755 --- a/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc.sh +++ b/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc.sh @@ -50,7 +50,7 @@ function asciidoc { # Verify, initialize or merge portable objects from portable # object templates. - locale_updateMessagePObjects "${POT_FILE}" "${PO_FILE}" + locale_convertPotToPo "${POT_FILE}" "${PO_FILE}" done diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Sh/sh.sh b/Automation/Modules/Locale/Modules/Update/Modules/Sh/sh.sh index d063500..5b10d58 100755 --- a/Automation/Modules/Locale/Modules/Update/Modules/Sh/sh.sh +++ b/Automation/Modules/Locale/Modules/Update/Modules/Sh/sh.sh @@ -42,7 +42,7 @@ function sh { # Verify, initialize or update portable objects from portable # object templates. - locale_updateMessagePObjects "${POT_FILE}" "${PO_FILE}" + locale_convertPotToPo "${POT_FILE}" "${PO_FILE}" # At this point some changes might be realized inside the PO file, # so we need to update the related MO file based on recently @@ -50,6 +50,6 @@ function sh { # print out the most up to date revision of localized messages. # Notice that this is required only if we were localizing shell # scripts. - locale_updateMessageBinary + locale_convertPoToMo } diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.sh b/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.sh index f5e6ffe..6950080 100755 --- a/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.sh +++ b/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.sh @@ -48,7 +48,7 @@ function svg { # Verify, initialize or merge portable objects from portable # object templates. - locale_updateMessagePObjects "${POT_FILE}" "${PO_FILE}" + locale_convertPotToPo "${POT_FILE}" "${PO_FILE}" done diff --git a/Automation/Modules/Locale/locale_convertPoToMo.sh b/Automation/Modules/Locale/locale_convertPoToMo.sh new file mode 100755 index 0000000..98bafde --- /dev/null +++ b/Automation/Modules/Locale/locale_convertPoToMo.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# +# locale_convertPoToMo.sh -- This function creates/updates +# machine objects (.mo) from portable objects (.po). +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function locale_convertPoToMo { + + # Print action message. + tcar_printMessage "${MO_FILE}" --as-creating-line + + # Verify absolute path to machine object directory, if it doesn't + # exist create it. + if [[ ! -d $(dirname ${MO_FILE}) ]];then + mkdir -p $(dirname ${MO_FILE}) + fi + + # Create machine object from portable object. + msgfmt --check ${PO_FILE} --output-file=${MO_FILE} + +} diff --git a/Automation/Modules/Locale/locale_convertPotToPo.sh b/Automation/Modules/Locale/locale_convertPotToPo.sh new file mode 100755 index 0000000..035ec45 --- /dev/null +++ b/Automation/Modules/Locale/locale_convertPotToPo.sh @@ -0,0 +1,70 @@ +#!/bin/bash +###################################################################### +# +# Modules/Locale/locale_convertPotToPo.sh -- This function +# initializes the portable object when it doesn't exist. When the +# portable object does exist, it is updated instead. In both cases, +# the portable object template is used as source to merge changes +# inside the portable object. +# +# Written by: +# * Alain Reguera Delgado +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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_convertPotToPo { + + local POT_FILE="${1}" + local PO_FILE="${2}" + + # Verify the portable object template. The portable object + # template is used to create the portable object. We cannot + # continue without it. + tcar_checkFiles -ef ${POT_FILE} + + # Create the PO's parent directory if it doesn't exist. + if [[ ! -d $(dirname ${PO_FILE}) ]];then + mkdir -p $(dirname ${PO_FILE}) + fi + + # Print action message. + tcar_printMessage "${PO_FILE}" --as-creating-line + + # Verify existence of portable object. The portable object is the + # file translators edit in order to make translation works. + if [[ -f ${PO_FILE} ]];then + + # Update portable object merging both portable object and + # portable object template. + msgmerge --output-file="${PO_FILE}" "${PO_FILE}" "${POT_FILE}" --quiet + + else + + # Initiate portable object using portable object template. + # Do not print msginit sterr output, use centos-art action + # message instead. + msginit -i ${POT_FILE} -o ${PO_FILE} --width=70 \ + --no-translator > /dev/null 2>&1 + + fi + + # Sanitate metadata inside the PO file. + locale_updatePoMetadata "${PO_FILE}" + +} diff --git a/Automation/Modules/Locale/locale_updateMessageBinary.sh b/Automation/Modules/Locale/locale_updateMessageBinary.sh deleted file mode 100755 index 10bfeb9..0000000 --- a/Automation/Modules/Locale/locale_updateMessageBinary.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# -# locale_updateMessageBinary.sh -- This function creates/updates -# machine objects (.mo) from portable objects (.po). -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function locale_updateMessageBinary { - - # Print action message. - tcar_printMessage "${MO_FILE}" --as-creating-line - - # Verify absolute path to machine object directory, if it doesn't - # exist create it. - if [[ ! -d $(dirname ${MO_FILE}) ]];then - mkdir -p $(dirname ${MO_FILE}) - fi - - # Create machine object from portable object. - msgfmt --check ${PO_FILE} --output-file=${MO_FILE} - -} diff --git a/Automation/Modules/Locale/locale_updateMessageMetadata.sh b/Automation/Modules/Locale/locale_updateMessageMetadata.sh deleted file mode 100755 index 2dea683..0000000 --- a/Automation/Modules/Locale/locale_updateMessageMetadata.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -###################################################################### -# -# locale_updateMessageMetadata.sh -- This function sanitates .pot -# and .po files to use common translation markers inside top -# comment. Later, replacement of common translation markers is -# applied to set the final information. -# -# Written by: -# * Alain Reguera Delgado -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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 PURPO_FILESE. 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_updateMessageMetadata { - - local COUNT=0 - local -a SRC - local -a DST - - # Retrieve absolute path of portable object we'll work with. - local PO_FILE="${1}" - - # Check existence of file before work with it. - tcar_checkFiles -ef "${PO_FILE}" - - # Define pattern lines. The pattern lines are put inside portable - # objects through xgettext and xml2po commands. In the case of - # Last-Translators, be sure to remplace it only when it is empty - # or refer the Documentation SIG only. This way translators' names - # will survive metadata updates. We don't want they have to type - # their name each time they edit a file. - SRC[0]="\"Project-Id-Version: (.+)?" - SRC[1]="\"Last-Translator: (.+)?" - SRC[2]="\"Language-Team: (.+)?" - SRC[3]="\"PO-Revision-Date: (.+)?" - - # Define replacement lines for pattern line. - DST[0]="\"Project-Id-Version: ${TCAR_SCRIPT_NAME} ${TCAR_SCRIPT_VERSION}\\\n\"" - DST[1]="\"Last-Translator: Localization SIG \\\n\"" - DST[2]="\"Language-Team: $(locale_getLanguageName)\\\n\"" - DST[3]="\"PO-Revision-Date: $(date "+%F %H:%M%z")\\\n\"" - - # Change pattern lines with their replacement lines. - while [[ ${COUNT} -lt ${#SRC[*]} ]];do - sed -i -r "/${SRC[${COUNT}]}/c${DST[${COUNT}]}" ${PO_FILE} - COUNT=$((${COUNT} + 1)) - done - - # Replace package information using gettext domain information. - sed -i -r "s/PACKAGE/${TCAR_SCRIPT_NAME}-${TCAR_SCRIPT_VERSION}/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 - # their working copies in different locations and we don't want to - # version those changes each time a translation message be - # updated. To be consistent about this, show path information from - # first level on. Don't show the variable part of the path. - sed -i -r "s,${TCAR_BASEDIR}/,,g" ${PO_FILE} - - # Unset array variables to avoid undesired concatenations. - unset SRC - unset DST - -} diff --git a/Automation/Modules/Locale/locale_updateMessagePObjects.sh b/Automation/Modules/Locale/locale_updateMessagePObjects.sh deleted file mode 100755 index 664e0e8..0000000 --- a/Automation/Modules/Locale/locale_updateMessagePObjects.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -###################################################################### -# -# Modules/Locale/locale_updateMessagePObjects.sh -- This function -# initializes the portable object when it doesn't exist. When the -# portable object does exist, it is updated instead. In both cases, -# the portable object template is used as source to merge changes -# inside the portable object. -# -# Written by: -# * Alain Reguera Delgado -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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_updateMessagePObjects { - - local POT_FILE="${1}" - local PO_FILE="${2}" - - # Verify the portable object template. The portable object - # template is used to create the portable object. We cannot - # continue without it. - tcar_checkFiles -ef ${POT_FILE} - - # Create the PO's parent directory if it doesn't exist. - if [[ ! -d $(dirname ${PO_FILE}) ]];then - mkdir -p $(dirname ${PO_FILE}) - fi - - # Print action message. - tcar_printMessage "${PO_FILE}" --as-creating-line - - # Verify existence of portable object. The portable object is the - # file translators edit in order to make translation works. - if [[ -f ${PO_FILE} ]];then - - # Update portable object merging both portable object and - # portable object template. - msgmerge --output-file="${PO_FILE}" "${PO_FILE}" "${POT_FILE}" --quiet - - else - - # Initiate portable object using portable object template. - # Do not print msginit sterr output, use centos-art action - # message instead. - msginit -i ${POT_FILE} -o ${PO_FILE} --width=70 \ - --no-translator > /dev/null 2>&1 - - fi - - # Sanitate metadata inside the PO file. - locale_updateMessageMetadata "${PO_FILE}" - -} diff --git a/Automation/Modules/Locale/locale_updatePoMetadata.sh b/Automation/Modules/Locale/locale_updatePoMetadata.sh new file mode 100755 index 0000000..5aeefc5 --- /dev/null +++ b/Automation/Modules/Locale/locale_updatePoMetadata.sh @@ -0,0 +1,80 @@ +#!/bin/bash +###################################################################### +# +# locale_updatePoMetadata.sh -- This function sanitates .pot +# and .po files to use common translation markers inside top +# comment. Later, replacement of common translation markers is +# applied to set the final information. +# +# Written by: +# * Alain Reguera Delgado +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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 PURPO_FILESE. 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_updatePoMetadata { + + local COUNT=0 + local -a SRC + local -a DST + + # Retrieve absolute path of portable object we'll work with. + local PO_FILE="${1}" + + # Check existence of file before work with it. + tcar_checkFiles -ef "${PO_FILE}" + + # Define pattern lines. The pattern lines are put inside portable + # objects through xgettext and xml2po commands. In the case of + # Last-Translators, be sure to remplace it only when it is empty + # or refer the Documentation SIG only. This way translators' names + # will survive metadata updates. We don't want they have to type + # their name each time they edit a file. + SRC[0]="\"Project-Id-Version: (.+)?" + SRC[1]="\"Last-Translator: (.+)?" + SRC[2]="\"Language-Team: (.+)?" + SRC[3]="\"PO-Revision-Date: (.+)?" + + # Define replacement lines for pattern line. + DST[0]="\"Project-Id-Version: ${TCAR_SCRIPT_NAME} ${TCAR_SCRIPT_VERSION}\\\n\"" + DST[1]="\"Last-Translator: Localization SIG \\\n\"" + DST[2]="\"Language-Team: $(locale_getLanguageName)\\\n\"" + DST[3]="\"PO-Revision-Date: $(date "+%F %H:%M%z")\\\n\"" + + # Change pattern lines with their replacement lines. + while [[ ${COUNT} -lt ${#SRC[*]} ]];do + sed -i -r "/${SRC[${COUNT}]}/c${DST[${COUNT}]}" ${PO_FILE} + COUNT=$((${COUNT} + 1)) + done + + # Replace package information using gettext domain information. + sed -i -r "s/PACKAGE/${TCAR_SCRIPT_NAME}-${TCAR_SCRIPT_VERSION}/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 + # their working copies in different locations and we don't want to + # version those changes each time a translation message be + # updated. To be consistent about this, show path information from + # first level on. Don't show the variable part of the path. + sed -i -r "s,${TCAR_BASEDIR}/,,g" ${PO_FILE} + + # Unset array variables to avoid undesired concatenations. + unset SRC + unset DST + +}