Imported Upstream version 0.18.1.1
[platform/upstream/gettext.git] / gettext-tools / tests / xgettext-po-1
1 #! /bin/sh
2
3 # Test C, C++, PO extractors.
4
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
7
8 tmpfiles="$tmpfiles xg-po-1.in.po xg-po-1.c xg-po-1.cc"
9 cat <<EOF > xg-po-1.in.po
10 #: file1.c:199
11 #, fuzzy
12 msgid "extract me"
13 msgstr "some text to get fuzzy copied to result"
14
15 #: file2.cc:200
16 msgid "what about me"
17 msgstr ""
18
19 #: file3.c:10
20 #, c-format, fuzzy
21 msgid "hello"
22 msgstr "Again some text for fuzzy"
23 EOF
24
25 cat <<EOF > xg-po-1.c
26 #include <libintl.h>
27 #include <stdio.h>
28 int
29 main (int argc, char *argv[])
30 {
31   printf (dcgettext ("hello", "Hello, world."));
32   return 0;
33 }
34 EOF
35
36 cat <<EOF > xg-po-1.cc
37 #include <iostream.h>
38 #include <libintl.h>
39 #include <locale.h>
40 int
41 main (int argc, char *argv[])
42 {
43   cout << dcgettext ("hello", "Hello world!", LC_MESSAGES) << endl;
44   return 0;
45 }
46 EOF
47
48 tmpfiles="$tmpfiles xg-po-1.tmp.po xg-po-1.po"
49 : ${XGETTEXT=xgettext}
50 ${XGETTEXT} --omit-header -n \
51   -d xg-po-1.tmp xg-po-1.in.po xg-po-1.c xg-po-1.cc
52 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
53 LC_ALL=C tr -d '\r' < xg-po-1.tmp.po > xg-po-1.po
54 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
55
56 tmpfiles="$tmpfiles xg-po-1.ok"
57 cat <<EOF > xg-po-1.ok
58 #: file1.c:199
59 #, fuzzy
60 msgid "extract me"
61 msgstr "some text to get fuzzy copied to result"
62
63 #: file2.cc:200
64 msgid "what about me"
65 msgstr ""
66
67 #: file3.c:10
68 #, fuzzy, c-format
69 msgid "hello"
70 msgstr "Again some text for fuzzy"
71
72 #: xg-po-1.c:6
73 #, c-format
74 msgid "Hello, world."
75 msgstr ""
76
77 #: xg-po-1.cc:7
78 msgid "Hello world!"
79 msgstr ""
80 EOF
81
82 : ${DIFF=diff}
83 ${DIFF} xg-po-1.ok xg-po-1.po
84 result=$?
85
86 rm -fr $tmpfiles
87
88 exit $result