#!/bin/bash
######################################################################
#
# file.sh -- This module standardize localization of files inside
# the repository.
#
# Written by:
# * Alain Reguera Delgado <al@centos.org.cu>, 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 file {
# Define absolute path to argument passed in the command-line.
local FILE=$(tcar_checkRepoDirSource "${1}")
# Verify argument passed in the command-line does exist and is a
# regular file.
tcar_checkFiles -ef ${FILE}
# Define file name.
local FILE_NAME="$(basename ${FILE})"
# Define file extension.
local FILE_EXTENSION=$(echo ${FILE} | sed -r 's/.+\.([[:alnum:]]+)$/\1/')
# Define absolute path to directory holding the files to process.
local DIRECTORY=$(dirname ${FILE})
# Define list of files to process.
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
local PO_FILE=${LOCALE_FROM}/${TCAR_SCRIPT_LANG_LC}/${FILE_NAME}.po
local MO_FILE=${LOCALE_FROM}/${TCAR_SCRIPT_LANG_LC}/LC_MESSAGES/${FILE_NAME}.mo
# Define the rendition type you want to perform.
local RENDER_TYPE=${FILE_EXTENSION}
# Define the translation file you want to use.
local -a TRANSLATIONS
TRANSLATIONS[0]=${PO_FILE}
# Define translation file. This is from which translatable strings
# will be retrieved.
local -a SOURCES
for SOURCE in ${RENDER_FROM};do
SOURCES[((++${#SOURCES[*]}))]=${SOURCE}
done
# Process configuration variables through locale's actions module.
tcar_setModuleEnvironment -m "actions" -t "sib-module"
}