Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / msgfmt-desktop-2
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test 'bulk' mode of Desktop Entry support.
5
6 cat <<\EOF > mf.desktop
7 [Desktop Entry]
8 Type=Application
9 Name =Foo
10
11 Comment[foo]=Already translated comment
12 Comment= \sThis is a \nmultiline comment; for testing
13 # This is a comment and must be preserved
14 Keywords=Keyword1;Keyword2;Key\;word3;
15 EOF
16
17 test -d po || mkdir po
18
19 cat <<\EOF > po/fr.po
20 # SOME DESCRIPTIVE TITLE.
21 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
22 # This file is distributed under the same license as the PACKAGE package.
23 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
24 #
25 #, fuzzy
26 msgid ""
27 msgstr ""
28 "Project-Id-Version: PACKAGE VERSION\n"
29 "Report-Msgid-Bugs-To: \n"
30 "POT-Creation-Date: 2014-03-17 07:36+0900\n"
31 "PO-Revision-Date: 2014-03-17 08:40+0900\n"
32 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
33 "Language-Team: LANGUAGE <LL@li.org>\n"
34 "Language: \n"
35 "MIME-Version: 1.0\n"
36 "Content-Type: text/plain; charset=UTF-8\n"
37 "Content-Transfer-Encoding: 8bit\n"
38
39 #: xg.desktop:4
40 msgid "Foo"
41 msgstr ""
42 "French\n"
43 "foo"
44
45 #: xg.desktop:5
46 msgid ""
47 " This is a \n"
48 "multiline comment; for testing"
49 msgstr ""
50 "French \n"
51 "comment"
52
53 #: xg.desktop:7
54 msgid "Keyword1;Keyword2;Key\\;word3;"
55 msgstr "one;two;thr\\;ee;"
56 EOF
57
58 cat <<\EOF > po/de.po
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 "POT-Creation-Date: 2014-03-17 07:36+0900\n"
70 "PO-Revision-Date: 2014-03-17 08:40+0900\n"
71 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
72 "Language-Team: LANGUAGE <LL@li.org>\n"
73 "Language: \n"
74 "MIME-Version: 1.0\n"
75 "Content-Type: text/plain; charset=UTF-8\n"
76 "Content-Transfer-Encoding: 8bit\n"
77
78 #: xg.desktop:4
79 msgid "Foo"
80 msgstr ""
81 "German\n"
82 "foo"
83
84 #: xg.desktop:5
85 msgid ""
86 " This is a \n"
87 "multiline comment; for testing"
88 msgstr ""
89 "German \n"
90 "comment"
91
92 #: xg.desktop:7
93 msgid "Keyword1;Keyword2;Key\\;word3;"
94 msgstr "one;two;thr\\;ee;"
95 EOF
96
97 cat <<\EOF > mf.desktop.ok
98 [Desktop Entry]
99 Type=Application
100 Name[de]=German\nfoo
101 Name[fr]=French\nfoo
102 Name=Foo
103
104 Comment[foo]=Already translated comment
105 Comment[de]=German \ncomment
106 Comment[fr]=French \ncomment
107 Comment=\sThis is a \nmultiline comment; for testing
108 # This is a comment and must be preserved
109 Keywords[de]=one;two;thr\;ee;
110 Keywords[fr]=one;two;thr\;ee;
111 Keywords=Keyword1;Keyword2;Key\;word3;
112 EOF
113
114 cat <<\EOF > mf.desktop.desired.ok
115 [Desktop Entry]
116 Type=Application
117 Name[fr]=French\nfoo
118 Name=Foo
119
120 Comment[foo]=Already translated comment
121 Comment[fr]=French \ncomment
122 Comment=\sThis is a \nmultiline comment; for testing
123 # This is a comment and must be preserved
124 Keywords[fr]=one;two;thr\;ee;
125 Keywords=Keyword1;Keyword2;Key\;word3;
126 EOF
127
128 unset LINGUAS
129
130 # Sanity checks for contradicting options.
131
132 ${MSGFMT} --desktop --template=mf.desktop -d po -o mf.desktop.out \
133           >/dev/null 2>/dev/null \
134   exit 1
135
136 test -d po/LINGUAS || mkdir po/LINGUAS
137
138 ${MSGFMT} --desktop --template=mf.desktop -d po -o mf.desktop.out \
139           >/dev/null 2>/dev/null \
140   exit 1
141
142 rm -fr po/LINGUAS
143
144 cat <<\EOF > po/LINGUAS
145 de
146 fr
147 EOF
148
149 ${MSGFMT} --desktop --template=mf.desktop -d po \
150           >/dev/null 2>/dev/null \
151   && exit 1
152
153 ${MSGFMG} --desktop --template=mf.desktop -d po -o mf.desktop.out -l fr \
154           >/dev/null 2>/dev/null \
155   && exit 1
156
157 ${MSGFMG} --desktop --template=mf.desktop -d po -o mf.desktop.out po/fr.po \
158           >/dev/null 2>/dev/null \
159   && exit 1
160
161 # Proceed to the .desktop file generation.
162
163 ${MSGFMT} --desktop --template=mf.desktop -d po -o mf.desktop.out || exit 1
164
165 : ${DIFF=diff}
166 ${DIFF} mf.desktop.ok mf.desktop.out
167 test $? = 0 || exit 1
168
169 # Restrict the desired languages with the LINGUAS envvar.
170
171 LINGUAS="fr ja" ${MSGFMT} --desktop --template=mf.desktop -d po -o mf.desktop.desired.out || exit 1
172
173 : ${DIFF=diff}
174 ${DIFF} mf.desktop.desired.ok mf.desktop.desired.out
175 test $? = 0 || exit 1