Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / xgettext-desktop-1
1 #!/bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test of Desktop Entry support.
5
6 : ${XGETTEXT=xgettext}
7
8 cat <<\EOF >err1.desktop
9 [Desktop Entry]
10 This is an invalid line
11 Name =Foo
12 EOF
13
14 (LANGUAGE= LC_ALL=C ${XGETTEXT} --add-comments -o - err1.desktop 2>&1; exit) | grep "missing '=' after" || exit 1
15
16 cat <<\EOF >err2.desktop
17 [Desktop Entry
18 EOF
19
20 (LANGUAGE= LC_ALL=C ${XGETTEXT} --add-comments -o - err2.desktop 2>&1; exit) | grep "unterminated group name" || exit 1
21
22 cat <<\EOF >err3.desktop
23 [Desktop Entry]
24   Not a blank line!
25 EOF
26
27 (LANGUAGE= LC_ALL=C ${XGETTEXT} --add-comments -o - err3.desktop 2>&1; exit) | grep "invalid non-blank line" || exit 1
28
29 cat <<\EOF >err4.desktop
30 [Desktop Entry]a
31 EOF
32
33 (LANGUAGE= LC_ALL=C ${XGETTEXT} --add-comments -o - err4.desktop 2>&1; exit) | grep "invalid non-blank character" || exit 1
34
35 # gettext 0.19.4 issued an baseless warning of this.
36 cat <<\EOF >ok4.desktop
37 [Desktop Entry]
38 EOF
39
40 (LANGUAGE= LC_ALL=C ${XGETTEXT} --add-comments -o - ok4.desktop 2>&1; exit) | grep "invalid non-blank character" && exit 1
41
42 cat <<\EOF > xg.desktop
43 [Desktop Entry]
44 Type=Application
45 Name =Foo
46 # This is a comment for comment
47 #   This is a comment for comment  
48 Comment= \sThis is a \nmultiline\t comment; for testing
49 Comment[foo]=Already translated comment
50 X-Foo = bar
51 # This is a comment before a blank line
52
53 Keywords=Keyword1;Keyword2;Key\;word3;
54 EOF
55
56 ${XGETTEXT} --add-comments -o - xg.desktop | grep -v 'POT-Creation-Date' > xg-desktop.pot || exit 1
57
58 cat <<\EOF > xg-desktop.ok
59 # SOME DESCRIPTIVE TITLE.
60 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
61 # This file is distributed under the same license as the PACKAGE package.
62 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
63 #
64 #, fuzzy
65 msgid ""
66 msgstr ""
67 "Project-Id-Version: PACKAGE VERSION\n"
68 "Report-Msgid-Bugs-To: \n"
69 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
70 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
71 "Language-Team: LANGUAGE <LL@li.org>\n"
72 "Language: \n"
73 "MIME-Version: 1.0\n"
74 "Content-Type: text/plain; charset=CHARSET\n"
75 "Content-Transfer-Encoding: 8bit\n"
76
77 #: xg.desktop:4
78 msgid "Foo"
79 msgstr ""
80
81 #. This is a comment for comment
82 #. This is a comment for comment
83 #: xg.desktop:7
84 msgid ""
85 " This is a \n"
86 "multiline\t comment; for testing"
87 msgstr ""
88
89 #: xg.desktop:12
90 msgid "Keyword1;Keyword2;Key\\;word3;"
91 msgstr ""
92 EOF
93
94 : ${DIFF=diff}
95 ${DIFF} xg-desktop.ok xg-desktop.pot
96 result=$?
97
98 exit $result