# Copyright (C) 1995 Free Software Foundation, Inc.
# Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995
#
# 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Shell script excerpt to be inserted in shell scripts which are intended
# to be internationalized using GNU gettext.
#
# Precondition:
# ${PACKAGE-IDENT} is the name of one program of the package which
#		understands the --print-text-domain-dir option
# ${PACKAGE-NAME} is the name of the message domain the package uses
# ${PATH}	should list all directories which should be searched
#		for either `gettext' or ${PACKAGE-IDENT}.
#
# Postcondition:
# ${echo}	command to use like Un*x echo command which translates
#		its arguments when a translation is available.
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
for dir in ${PATH}
do
  if test "${gettext_dir}" = "FAILED" && test -x ${dir}/gettext \
     && (${dir}/gettext --version >/dev/null 2>&1)
  then
    set `${dir}/gettext --version 2>&1`
    if test "$3" = "GNU"
    then
      gettext_dir=${dir}
    fi
  fi
  if test "${locale_dir}" = "FAILED" && test -x ${dir}/${PACKAGE-IDENT} \
     && (${dir}/${PACKAGE-IDENT} --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`${dir}/${PACKAGE-IDENT} --print-text-domain-dir`
  fi
done
IFS="${save_IFS}"
if test "${locale_dir}" = "FAILED" || test "${gettext_dir}" = "FAILED"
then
  echo=echo
else
  TEXTDOMAINDIR=${locale_dir}
  export TEXTDOMAINDIR
  TEXTDOMAIN=${PACKAGE-NAME}
  export TEXTDOMAIN
  echo="${gettext_dir}/gettext -s"
fi
