Blame gettext-tools/tests/lang-sh

Packit Bot 06c835
#! /bin/sh
Packit Bot 06c835
. "${srcdir=.}/init.sh"; path_prepend_ . ../src ${top_srcdir=..}/../gettext-runtime/src
Packit Bot 06c835
Packit Bot 06c835
# Test of gettext facilities in the sh language.
Packit Bot 06c835
# Assumes an fr_FR locale is installed.
Packit Bot 06c835
# Assumes the following packages are installed: bash.
Packit Bot 06c835
Packit Bot 06c835
# Note: This test fails on BeOS because there all locales use the UTF-8
Packit Bot 06c835
# encoding, even the locale fr_FR, thus the output comes out in UTF-8.
Packit Bot 06c835
Packit Bot 06c835
cat <<\EOF > prog.sh
Packit Bot 06c835
#! /bin/sh
Packit Bot 06c835
Packit Bot 06c835
n=$1
Packit Bot 06c835
Packit Bot 06c835
. gettext.sh
Packit Bot 06c835
Packit Bot 06c835
TEXTDOMAIN=prog
Packit Bot 06c835
export TEXTDOMAIN
Packit Bot 06c835
TEXTDOMAINDIR=.
Packit Bot 06c835
export TEXTDOMAINDIR
Packit Bot 06c835
Packit Bot 06c835
$echo "`gettext \"'Your command, please?', asked the waiter.\"`"
Packit Bot 06c835
Packit Bot 06c835
$echo "`eval_ngettext \"a piece of cake\" \"\\$n pieces of cake\" $n`"
Packit Bot 06c835
EOF
Packit Bot 06c835
Packit Bot 06c835
: ${XGETTEXT=xgettext}
Packit Bot 06c835
${XGETTEXT} -o prog.tmp --omit-header --no-location prog.sh || exit 1
Packit Bot 06c835
LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || exit 1
Packit Bot 06c835
Packit Bot 06c835
cat <<\EOF > prog.ok
Packit Bot 06c835
msgid "'Your command, please?', asked the waiter."
Packit Bot 06c835
msgstr ""
Packit Bot 06c835
Packit Bot 06c835
#, sh-format
Packit Bot 06c835
msgid "a piece of cake"
Packit Bot 06c835
msgid_plural "$n pieces of cake"
Packit Bot 06c835
msgstr[0] ""
Packit Bot 06c835
msgstr[1] ""
Packit Bot 06c835
EOF
Packit Bot 06c835
Packit Bot 06c835
: ${DIFF=diff}
Packit Bot 06c835
${DIFF} prog.ok prog.pot || exit 1
Packit Bot 06c835
Packit Bot 06c835
cat <<\EOF > fr.po
Packit Bot 06c835
msgid ""
Packit Bot 06c835
msgstr ""
Packit Bot 06c835
"Content-Type: text/plain; charset=ISO-8859-1\n"
Packit Bot 06c835
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
Packit Bot 06c835
Packit Bot 06c835
msgid "'Your command, please?', asked the waiter."
Packit Bot 06c835
msgstr "«Votre commande, s'il vous plait», dit le garçon."
Packit Bot 06c835
Packit Bot 06c835
# Les gateaux allemands sont les meilleurs du monde.
Packit Bot 06c835
#, sh-format
Packit Bot 06c835
msgid "a piece of cake"
Packit Bot 06c835
msgid_plural "$n pieces of cake"
Packit Bot 06c835
msgstr[0] "un morceau de gateau"
Packit Bot 06c835
msgstr[1] "$n morceaux de gateau"
Packit Bot 06c835
EOF
Packit Bot 06c835
Packit Bot 06c835
: ${MSGMERGE=msgmerge}
Packit Bot 06c835
${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || exit 1
Packit Bot 06c835
LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || exit 1
Packit Bot 06c835
Packit Bot 06c835
: ${DIFF=diff}
Packit Bot 06c835
${DIFF} fr.po fr.po.new || exit 1
Packit Bot 06c835
Packit Bot 06c835
test -d fr || mkdir fr
Packit Bot 06c835
test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
Packit Bot 06c835
Packit Bot 06c835
: ${MSGFMT=msgfmt}
Packit Bot 06c835
${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
Packit Bot 06c835
Packit Bot 06c835
# Test which of the fr_FR locales are installed.
Packit Bot 06c835
: ${LOCALE_FR=fr_FR}
Packit Bot 06c835
: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
Packit Bot 06c835
if test $LOCALE_FR != none; then
Packit Bot 06c835
  LC_ALL=$LOCALE_FR ../testlocale
Packit Bot 06c835
  case $? in
Packit Bot 06c835
    0) ;;
Packit Bot 06c835
    77) LOCALE_FR=none;;
Packit Bot 06c835
    *) exit 1;;
Packit Bot 06c835
  esac
Packit Bot 06c835
fi
Packit Bot 06c835
if test $LOCALE_FR_UTF8 != none; then
Packit Bot 06c835
  LC_ALL=$LOCALE_FR_UTF8 ../testlocale
Packit Bot 06c835
  case $? in
Packit Bot 06c835
    0) ;;
Packit Bot 06c835
    77) LOCALE_FR_UTF8=none;;
Packit Bot 06c835
    *) exit 1;;
Packit Bot 06c835
  esac
Packit Bot 06c835
fi
Packit Bot 06c835
if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
Packit Bot 06c835
  if test -f /usr/bin/localedef; then
Packit Bot 06c835
    echo "Skipping test: no french locale is installed"
Packit Bot 06c835
  else
Packit Bot 06c835
    echo "Skipping test: no french locale is supported"
Packit Bot 06c835
  fi
Packit Bot 06c835
  exit 77
Packit Bot 06c835
fi
Packit Bot 06c835
Packit Bot 06c835
: ${DIFF=diff}
Packit Bot 06c835
cat <<\EOF > prog.ok
Packit Bot 06c835
«Votre commande, s'il vous plait», dit le garçon.
Packit Bot 06c835
2 morceaux de gateau
Packit Bot 06c835
EOF
Packit Bot 06c835
cat <<\EOF > prog.oku
Packit Bot 06c835
«Votre commande, s'il vous plait», dit le garçon.
Packit Bot 06c835
2 morceaux de gateau
Packit Bot 06c835
EOF
Packit Bot 06c835
Packit Bot 06c835
: ${LOCALE_FR=fr_FR}
Packit Bot 06c835
: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
Packit Bot 06c835
if test $LOCALE_FR != none; then
Packit Bot 06c835
  prepare_locale_ fr $LOCALE_FR
Packit Bot 06c835
  LANGUAGE= LC_ALL=$LOCALE_FR sh ./prog.sh 2 > prog.out || exit 1
Packit Bot 06c835
  ${DIFF} prog.ok prog.out || exit 1
Packit Bot 06c835
fi
Packit Bot 06c835
if test $LOCALE_FR_UTF8 != none; then
Packit Bot 06c835
  prepare_locale_ fr $LOCALE_FR_UTF8
Packit Bot 06c835
  LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 sh ./prog.sh 2 > prog.out || exit 1
Packit Bot 06c835
  ${DIFF} prog.oku prog.out || exit 1
Packit Bot 06c835
fi
Packit Bot 06c835
Packit Bot 06c835
exit 0