/
01-basic.t
324 lines (260 loc) · 9.31 KB
/
01-basic.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
use v6;
use Test;
use POFile;
my ($PO, $result);
$PO = q:to/END/;
#: finddialog.cpp:38
msgid "Globular Clusters"
msgstr ""
#: finddialog.cpp:39
msgid "Gaseous Nebulae"
msgstr ""
#: finddialog.cpp:40
msgid "Planetary Nebulae"
msgstr ""
END
lives-ok { $result = POFile.parse($PO) }, 'msgid, msgstr with source reference comment';
ok $result[0].reference eq 'finddialog.cpp:38', 'First comment is set';
ok $result{'Planetary Nebulae'}.reference eq 'finddialog.cpp:40', 'Third comment is set';
is ~$result, $PO, 'Serialization is done';
$PO = q:to/END/;
#: finddialog.cpp:38
msgid "Globular Clusters"
msgstr "Globularna jata"
#: finddialog.cpp:39
msgid "Gaseous Nebulae"
msgstr "Gasne magline"
#: finddialog.cpp:40
msgid "Planetary Nebulae"
msgstr "Planetarne magline"
END
lives-ok { $result = POFile.parse($PO) }, 'msgid, msgstr with source reference comment';
ok $result[0].msgstr eq 'Globularna jata', 'First msgstr is set';
ok $result{'Planetary Nebulae'}.msgstr eq 'Planetarne magline', 'Third msgstr is set';
is ~$result, $PO, 'Serialization is done';
$PO = q:to/END/;
#: indimenu.cpp:96
msgid ""
"No INDI devices currently running. To run devices, please select devices "
"from the Device Manager in the devices menu."
msgstr ""
END
lives-ok { $result = POFile.parse($PO) }, 'Multi-line msgid';
ok $result[0].msgid eq 'No INDI devices currently running. To run devices, please select devices from the Device Manager in the devices menu.', 'Multi-line un-quoted correctly';
$PO = q:to/END/;
#. TRANSLATORS: A test phrase with all letters of the English alphabet.
#. Replace it with a sample text in your language, such that it is
#. representative of language's writing system.
#: kdeui/fonts/kfontchooser.cpp:382
msgid "The Quick Brown Fox Jumps Over The Lazy Dog"
msgstr ""
END
lives-ok { $result = POFile.parse($PO) }, 'Extracted comments';
ok $result[0].extracted eq 'TRANSLATORS: A test phrase with all letters of the English alphabet.Replace it with a sample text in your language, such that it isrepresentative of language\'s writing system.', 'Extracted comment is set';
$PO = q:to/END/;
#: tools/observinglist.cpp:700
msgctxt "First letter in 'Scope'"
msgid "S"
msgstr ""
#: skycomponents/horizoncomponent.cpp:429
msgctxt "South"
msgid "S"
msgstr ""
END
lives-ok { $result = POFile.parse($PO) }, 'Message context';
ok $result[0].msgctxt eq "First letter in 'Scope'", 'First msgctxt is set';
ok $result[1].msgctxt eq "South", 'Second msgctxt is set';
$PO = q:to/END/;
# Wikipedia says that ‘etrurski’ is our name for this script.
#: viewpart/UnicodeBlocks.h:151
msgid "Old Italic"
msgstr "etrurski"
END
lives-ok { $result = POFile.parse($PO) }, 'Translator comments';
ok $result[0].comment eq 'Wikipedia says that ‘etrurski’ is our name for this script.', 'Translator comment is set';
ok $result[0].reference eq 'viewpart/UnicodeBlocks.h:151', 'Reference comment is set';
$PO = q:to/END/;
#: skycomponents/constellationlines.cpp:106
#, kde-format
msgid "No star named %1 found."
msgstr "Nema zvezde po imenu %1."
END
lives-ok { $result = POFile.parse($PO) }, 'Format comment is set';
ok $result[0].format-style eq 'kde-format', 'Format comment is set';
$PO = q:to/END/;
#. Tag: title
#: blackbody.docbook:13
msgid "<title>Blackbody Radiation</title>"
msgstr ""
#. Tag: para
#: geocoords.docbook:28
msgid ""
"The Equator is obviously an important part of this coordinate system; "
"it represents the <emphasis>zeropoint</emphasis> of the latitude angle, "
"and the halfway point between the poles. The Equator is the "
"<firstterm>Fundamental Plane</firstterm> of the geographic coordinate "
"system. <link linkend='ai-skycoords'>All Spherical</link> Coordinate "
"Systems define such a Fundamental Plane."
msgstr ""
END
lives-ok { $result = POFile.parse($PO) }, 'Markup';
$PO = q:to/END/;
#: kstars_i18n.cpp:3591
msgid "The \"face\" on Mars"
msgstr "\"Lice\" na Marsu"
END
lives-ok { $result = POFile.parse($PO) }, 'Escape - double quote';
ok $result[0].msgid eq 'The "face" on Mars', 'Double quote is unescaped';
ok $result[0].msgid-quoted eq 'The \"face\" on Mars', 'msgid-unquoted returns quoted version';
ok $result[0].msgstr eq '"Lice" na Marsu', 'Double quote is unescaped';
ok $result[0].msgstr-quoted eq '\"Lice\" na Marsu', 'msgstr-unquoted returns quoted version';
$PO = q:to/END/;
#: kstarsinit.cpp:699
msgid ""
"The initial position is below the horizon.\n"
"Would you like to reset to the default position?"
msgstr ""
"Početni položaj je ispod horizonta.\n"
"Želite li da vratite na podrazumevani?"
END
lives-ok { $result = POFile.parse($PO) }, 'Escape - newline';
ok $result[0].msgid eq 'The initial position is below the horizon.\nWould you like to reset to the default position?', 'New line character is escaped';
$PO = q:to/END/;
msgid ""
"\t\\\t"
msgstr ""
END
lives-ok { $result = POFile.parse($PO) }, 'Escape - tab and backslash';
ok $result[0].msgid eq '\t\\t', 'Tabs and backslash symbols are escaped';
$PO = q:to/END/;
#: kstarsinit.cpp:163
msgid "Set Focus &Manually..."
msgstr "フォーカスを手動でセット(&M)..."
END
lives-ok { $result = POFile.parse($PO) }, 'Accelerator';
ok $result[0].msgstr eq 'フォーカスを手動でセット(&M)...', 'msgstr with accelerator is parsed and set';
$PO = q:to/END/;
#: kspopupmenu.cpp:203
msgid "Center && Track"
msgstr ""
#. Tag: phrase
#: config.docbook:137
msgid "<phrase>Configure &kstars; Window</phrase>"
msgstr ""
END
lives-ok { $result = POFile.parse($PO) }, 'Accelerator 2';
$PO = q:to/END/;
#: mainwindow.cpp:127
#, kde-format
msgid "Time: %1 second"
msgid_plural "Time: %1 seconds"
msgstr[0] "Czas: %1 sekunda"
msgstr[1] "Czas: %1 sekundy"
msgstr[2] "Czas: %1 sekund"
msgid "<phrase>Configure &kstars; Window</phrase>"
msgstr ""
END
lives-ok { $result = POFile.parse($PO) }, 'Plural forms';
ok $result[0].msgid-plural eq 'Time: %1 seconds', 'Plural form of msgid is set';
ok $result[0].msgstr[0] eq 'Czas: %1 sekunda', 'First plural message is set';
ok $result[0].msgstr[2] eq 'Czas: %1 sekund', 'Third plural message is set';
$PO = q:to/END/;
#: src/somwidget_impl.cpp:120
#, fuzzy
#| msgid "Elements with boiling point around this temperature:"
msgid "Elements with melting point around this temperature:"
msgstr "Elementi s tačkom ključanja u blizini ove temperature:"
END
lives-ok { $result = POFile.parse($PO) }, 'Fuzzy';
is $result[0].fuzzy-msgid, '"Elements with boiling point around this temperature:"', 'Fuzzy msgid is set';
$PO = q:to/END/;
#: kstarsinit.cpp:451
#, fuzzy
#| msgctxt "Constellation Line"
#| msgid "Constell. Line"
msgctxt "Toggle Constellation Lines in the display"
msgid "Const. Lines"
msgstr "Linija sazvežđa"
END
lives-ok { $result = POFile.parse($PO) }, 'Fuzzy 2';
is $result[0].fuzzy-msgctxt, '"Constellation Line"', 'Fuzzy msgctxt is set';
is $result[0].fuzzy-msgid, '"Constell. Line"', 'Fuzzy msgid is set';
$PO = q:to/END/;
#~ msgid "Set the telescope longitude and latitude."
#~ msgstr "Postavi geo. dužinu i širinu teleskopa."
END
lives-ok { $result = POFile.parse($PO) }, 'Obsolete messages';
is $result.obsolete-messages.elems, 2, 'Obsolete messages are parsed';
$PO = q:to/END/;
#: mainwindow.cpp:127
#, fuzzy
#| msgctxt "Postavi geo. dužinu i širinu teleskopa."
#| msgid "Set the telescope longitude and latitude."
msgid "Time: %1 second"
msgid_plural "Time: %1 seconds"
msgstr[0] "Czas: %1 sekunda"
msgstr[1] "Czas: %1 sekundy"
msgstr[2] "Czas: %1 sekund"
#~ msgid "Set the telescope longitude and latitude."
#~ msgstr "Postavi geo. dužinu i širinu teleskopa."
END
$result = POFile.parse($PO);
is ~$result, $PO.trim, 'Serialization is done';
$PO = q:to/END/;
#: mainwindow.cpp:127
#, fuzzy
#| msgctxt "Postavi geo. dužinu i širinu teleskopa."
#| msgid "Set the telescope longitude and latitude."
msgid "Time: %1 second"
msgid_plural "Time: %1 seconds"
msgstr[0] "Czas: %1 sekunda"
msgstr[1] "Czas: %1 sekundy"
msgstr[2] "Czas: %1 sekund"
END
my $item;
lives-ok { $item = POFile::Entry.parse($PO) }, 'Can parse single item';
$result.push($item);
$result.push($item);
my $three-messages = q:to/END/;
#: mainwindow.cpp:127
#, fuzzy
#| msgctxt "Postavi geo. dužinu i širinu teleskopa."
#| msgid "Set the telescope longitude and latitude."
msgid "Time: %1 second"
msgid_plural "Time: %1 seconds"
msgstr[0] "Czas: %1 sekunda"
msgstr[1] "Czas: %1 sekundy"
msgstr[2] "Czas: %1 sekund"
#: mainwindow.cpp:127
#, fuzzy
#| msgctxt "Postavi geo. dužinu i širinu teleskopa."
#| msgid "Set the telescope longitude and latitude."
msgid "Time: %1 second"
msgid_plural "Time: %1 seconds"
msgstr[0] "Czas: %1 sekunda"
msgstr[1] "Czas: %1 sekundy"
msgstr[2] "Czas: %1 sekund"
#: mainwindow.cpp:127
#, fuzzy
#| msgctxt "Postavi geo. dužinu i širinu teleskopa."
#| msgid "Set the telescope longitude and latitude."
msgid "Time: %1 second"
msgid_plural "Time: %1 seconds"
msgstr[0] "Czas: %1 sekunda"
msgstr[1] "Czas: %1 sekundy"
msgstr[2] "Czas: %1 sekund"
#~ msgid "Set the telescope longitude and latitude."
#~ msgstr "Postavi geo. dužinu i širinu teleskopa."
END
is $three-messages.trim, ~$result, 'New entries are correctly pushed';
lives-ok { $result = POFile.load('t/example.po') }, 'Test loading from file';
is $result.elems, 3, 'Loaded correct numbers of elements from file';
my $i = 0;
for @$result -> $item {
$i++;
}
is $i, 3, 'List-based iteration works';
$PO = "I will not be parsed!";
throws-like { POFile.parse($PO) },
POFile::CannotParse, 'Has typed exception on parsing failure';
done-testing;