Imported Upstream version 0.18.1.1
[platform/upstream/gettext.git] / gettext-tools / tests / xgettext-php-1
1 #!/bin/sh
2
3 # Test PHP support: --add-comments option.
4
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
7
8 tmpfiles="$tmpfiles xg-ph-1.php"
9 cat <<EOF > xg-ph-1.php
10 <?
11 // This comment will not be extracted.
12 echo _("help");
13 //  TRANSLATORS: This is an extracted comment.
14 echo _("me");
15 # TRANSLATORS: This is extracted too.
16 echo _("and you");
17 /* Not extracted either. */
18 echo _("Hey Jude");
19 /*  TRANSLATORS:
20      Nickname of the Beatles
21 */
22 echo _("The Fabulous Four");
23 // This will not be extracted.
24 echo _(table["key"]);
25 ?>
26 EOF
27
28 tmpfiles="$tmpfiles xg-ph-1.tmp.po xg-ph-1.po"
29 : ${XGETTEXT=xgettext}
30 ${XGETTEXT} --omit-header --no-location --add-comments=TRANSLATORS: \
31   -d xg-ph-1.tmp xg-ph-1.php
32 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
33 LC_ALL=C tr -d '\r' < xg-ph-1.tmp.po > xg-ph-1.po
34 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
35
36 tmpfiles="$tmpfiles xg-ph-1.ok"
37 cat <<EOF > xg-ph-1.ok
38 msgid "help"
39 msgstr ""
40
41 #. TRANSLATORS: This is an extracted comment.
42 msgid "me"
43 msgstr ""
44
45 #. TRANSLATORS: This is extracted too.
46 msgid "and you"
47 msgstr ""
48
49 msgid "Hey Jude"
50 msgstr ""
51
52 #. TRANSLATORS:
53 #. Nickname of the Beatles
54 #.
55 msgid "The Fabulous Four"
56 msgstr ""
57 EOF
58
59 : ${DIFF=diff}
60 ${DIFF} xg-ph-1.ok xg-ph-1.po
61 result=$?
62
63 rm -fr $tmpfiles
64
65 exit $result