Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

#! /bin/sh

# Test of gettext facilities in the PO/POT format.

tmpfiles=""
trap 'rm -fr $tmpfiles' 1 2 3 15

# Test with POT format.

tmpfiles="$tmpfiles prog-in.pot"
cat <<\EOF > prog-in.pot
msgid "'Your command, please?', asked the waiter."
msgstr ""

#, c-format
msgid "a piece of cake"
msgid_plural "%d pieces of cake"
msgstr[0] ""
msgstr[1] ""

#, c-format
msgid "%s is replaced by %s."
msgstr ""
EOF

tmpfiles="$tmpfiles prog.pot"
: ${XGETTEXT=xgettext}
${XGETTEXT} -o prog.pot --omit-header --add-location prog-in.pot

: ${DIFF=diff}
${DIFF} prog-in.pot prog.pot || exit 1

# Test with PO format.

tmpfiles="$tmpfiles prog-in.po"
cat <<\EOF > prog-in.po
msgid ""
msgstr ""
"Content-Type: text/plain; charset=ISO-8859-1\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

msgid "'Your command, please?', asked the waiter."
msgstr "«Votre commande, s'il vous plait», dit le garçon."

# Les gateaux allemands sont les meilleurs du monde.
#, c-format
msgid "a piece of cake"
msgid_plural "%d pieces of cake"
msgstr[0] "un morceau de gateau"
msgstr[1] "%d morceaux de gateau"

# Reverse the arguments.
#, c-format
msgid "%s is replaced by %s."
msgstr "%2$s remplace %1$s."
EOF

tmpfiles="$tmpfiles prog.po"
: ${XGETTEXT=xgettext}
${XGETTEXT} -o prog.po --omit-header --add-location prog-in.po

: ${DIFF=diff}
${DIFF} prog-in.po prog.po || exit 1

rm -fr $tmpfiles

exit 0