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