Imported Upstream version 0.18.3.2
[platform/upstream/gettext.git] / gettext-tools / tests / xgettext-lua-2
1 #!/bin/sh
2
3 # Test Lua support
4
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
7
8 tmpfiles="$tmpfiles xg-lu-2.lua"
9 cat <<\EOF > xg-lu-2.lua
10 -- This comment won't be extracted.
11 print(_"Hmm.")
12 -- Neither this one.
13 print(_"Test.")
14 --   TRANSLATORS: Hello translators, how are you today?
15 print(_"We're fine, thanks.")
16 --[[ Do not extract this, please ]]
17
18 --[[  TRANSLATORS:
19 Attention!
20 ]]
21 print(--[=[     TRANSLATORS: This is a comment for you!]=] _(--[[TRANSLATORS: Nobody else is supposed to read this!]]
22 "flowers" --[===[ TRANSLATORS: Nobody will see this.]===] .. --[[ TRANSLATORS: How sad.]] " and " .. --[[Secret text!]]
23 "biscuits" --[=[TRANSLATORS: Hey you!]=]))
24
25 --[==[TRANSLATORS: :-]]==]
26 print(_"A string.")
27 EOF
28
29 tmpfiles="$tmpfiles xg-lu-2.tmp.po xg-lu-2.po"
30 : ${XGETTEXT=xgettext}
31 ${XGETTEXT} --omit-header --no-location --add-comments=TRANSLATORS: \
32   -d xg-lu-2.tmp xg-lu-2.lua
33 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
34 LC_ALL=C tr -d '\r' < xg-lu-2.tmp.po > xg-lu-2.po
35 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
36
37 tmpfiles="$tmpfiles xg-lu-2.ok"
38 cat <<EOF > xg-lu-2.ok
39 msgid "Hmm."
40 msgstr ""
41
42 msgid "Test."
43 msgstr ""
44
45 #. TRANSLATORS: Hello translators, how are you today?
46 msgid "We're fine, thanks."
47 msgstr ""
48
49 #. TRANSLATORS:
50 #. Attention!
51 #.
52 #. TRANSLATORS: This is a comment for you!
53 #. TRANSLATORS: Nobody else is supposed to read this!
54 msgid "flowers and biscuits"
55 msgstr ""
56
57 #. TRANSLATORS: :-]
58 msgid "A string."
59 msgstr ""
60 EOF
61
62 : ${DIFF=diff}
63 ${DIFF} xg-lu-2.ok xg-lu-2.po
64 result=$?
65
66 rm -fr $tmpfiles
67
68 exit $result