• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2. "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4# Test 'bulk' mode of Desktop Entry support.
5
6cat <<\EOF > mf.desktop
7[Desktop Entry]
8Type=Application
9Name =Foo
10
11Comment[foo]=Already translated comment
12Comment= \sThis is a \nmultiline comment; for testing
13# This is a comment and must be preserved
14Keywords=Keyword1;Keyword2;Key\;word3;
15EOF
16
17test -d po || mkdir po
18
19cat <<\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
26msgid ""
27msgstr ""
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
40msgid "Foo"
41msgstr ""
42"French\n"
43"foo"
44
45#: xg.desktop:5
46msgid ""
47" This is a \n"
48"multiline comment; for testing"
49msgstr ""
50"French \n"
51"comment"
52
53#: xg.desktop:7
54msgid "Keyword1;Keyword2;Key\\;word3;"
55msgstr "one;two;thr\\;ee;"
56EOF
57
58cat <<\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
65msgid ""
66msgstr ""
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
79msgid "Foo"
80msgstr ""
81"German\n"
82"foo"
83
84#: xg.desktop:5
85msgid ""
86" This is a \n"
87"multiline comment; for testing"
88msgstr ""
89"German \n"
90"comment"
91
92#: xg.desktop:7
93msgid "Keyword1;Keyword2;Key\\;word3;"
94msgstr "one;two;thr\\;ee;"
95EOF
96
97cat <<\EOF > mf.desktop.ok
98[Desktop Entry]
99Type=Application
100Name[de]=German\nfoo
101Name[fr]=French\nfoo
102Name=Foo
103
104Comment[foo]=Already translated comment
105Comment[de]=German \ncomment
106Comment[fr]=French \ncomment
107Comment=\sThis is a \nmultiline comment; for testing
108# This is a comment and must be preserved
109Keywords[de]=one;two;thr\;ee;
110Keywords[fr]=one;two;thr\;ee;
111Keywords=Keyword1;Keyword2;Key\;word3;
112EOF
113
114cat <<\EOF > mf.desktop.desired.ok
115[Desktop Entry]
116Type=Application
117Name[fr]=French\nfoo
118Name=Foo
119
120Comment[foo]=Already translated comment
121Comment[fr]=French \ncomment
122Comment=\sThis is a \nmultiline comment; for testing
123# This is a comment and must be preserved
124Keywords[fr]=one;two;thr\;ee;
125Keywords=Keyword1;Keyword2;Key\;word3;
126EOF
127
128unset 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
136test -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
142rm -fr po/LINGUAS
143
144cat <<\EOF > po/LINGUAS
145de
146fr
147EOF
148
149${MSGFMT} --desktop --template=mf.desktop -d po \
150          >/dev/null 2>/dev/null \
151  && Exit 1
152
153${MSGFMT} --desktop --template=mf.desktop -d po -o mf.desktop.out -l fr \
154          >/dev/null 2>/dev/null \
155  && Exit 1
156
157${MSGFMT} --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.tmp || Exit 1
164LC_ALL=C tr -d '\r' < mf.desktop.tmp > mf.desktop.out || Exit 1
165
166: ${DIFF=diff}
167${DIFF} mf.desktop.ok mf.desktop.out
168test $? = 0 || Exit 1
169
170# Restrict the desired languages with the LINGUAS envvar.
171
172LINGUAS="fr ja" \
173${MSGFMT} --desktop --template=mf.desktop -d po -o mf.desktop.desired.tmp || Exit 1
174LC_ALL=C tr -d '\r' < mf.desktop.desired.tmp > mf.desktop.desired.out || Exit 1
175
176: ${DIFF=diff}
177${DIFF} mf.desktop.desired.ok mf.desktop.desired.out
178test $? = 0 || Exit 1
179