Math Processor Unit Library

libmpu – library of arithmetic functions for integer, real, and complex numbers of increased digit capacity

16 Commits   0 Branches   2 Tags
#!/bin/bash

CWD=`pwd`

SCRIPT_DIR=`cd $(dirname ${BASH_SOURCE[0]}) >/dev/null 2>&1 && pwd`
program=`basename $0`

save_new_version() {
  local ifile=${1}
  local ofile=${2}
  local iline=`cat ${ifile} | grep 'Project-Id-Version:'`
  local version=`echo ${iline} | cut -f2 -d':' | tr -s ' ' | sed 's,^[ \t]*,,' | sed 's,[ \t]*$,,' | sed 's,[\]n["]$,,'`

  local oline=`cat ${ofile} | grep -n 'Project-Id-Version:' | cut -f2,3 -d':'`
  local olnum=`cat ${ofile} | grep -n 'Project-Id-Version:' | cut -f1 -d':'`

  if [ ! -z "${oline}" -a -z "`echo ${oline} | grep "${version}"`" ] ; then
    echo "$ifile: Keep new 'Project-Id-Version: ${version}'"
       sed -i "${olnum} c\
\"Project-Id-Version: ${version}\\\n\"" ${ofile}
  fi
}

cd ${SCRIPT_DIR}/..

PACKAGE_VERSION=`cat configure.ac | grep AC_INIT | sed 's,.*\[\([.0-9]*\)\].*,\1,'`

POTFILE=po/libmpu.pot

if [ -f "$POTFILE" ] ; then
  cp -a ${POTFILE} ${POTFILE}~
fi

xgettext --from-code=UTF-8 --keyword=N_ --keyword=_ --keyword=Q_:1,2  \
         --language=C --add-comments --sort-output --no-wrap \
         --msgid-bugs-address="Andrey V.Kosteltsev <support@radix-linux.su>" \
         --package-name=libmpu \
         --package-version=${PACKAGE_VERSION} \
         --copyright-holder="Andrey V.Kosteltsev <kx@radix-linux.su>" \
         --default-domain=libmpu --output=${POTFILE} \
         `find -type f -name "*.c"`

( cd po ;
  _LOCALE=ru_RU.utf8
  _PO_FNAME=ru
  mv ${_PO_FNAME}.po ${_PO_FNAME}.po~
  echo -en "Create new ${_PO_FNAME}.po file:\n.. "
  msginit --no-translator --no-wrap --locale=${_LOCALE} --input=libmpu.pot --output-file=${_PO_FNAME}.po
  echo "Merge translated strings back ${_PO_FNAME}.po:"
  msgmerge --no-wrap --sort-output ${_PO_FNAME}.po~ ${_PO_FNAME}.po > ${_PO_FNAME}.po.new
  # ======= Save new version: =======
  save_new_version ${_PO_FNAME}.po ${_PO_FNAME}.po.new
  mv ${_PO_FNAME}.po.new ${_PO_FNAME}.po
#  rm -f ${_PO_FNAME}.po~
)

cd l10n