1 # -*- coding: utf-8 -*-
2 from translate
.filters
import checks
3 from translate
.lang
import data
4 from translate
.storage
import po
6 def strprep(str1
, str2
, message
=None):
7 return data
.forceunicode(str1
), data
.forceunicode(str2
), data
.forceunicode(message
)
9 def passes(filterfunction
, str1
, str2
):
10 """returns whether the given strings pass on the given test, handling FilterFailures"""
11 str1
, str2
, no_message
= strprep(str1
, str2
)
13 filterresult
= filterfunction(str1
, str2
)
14 except checks
.FilterFailure
, e
:
18 def fails(filterfunction
, str1
, str2
, message
=None):
19 """returns whether the given strings fail on the given test, handling only FilterFailures"""
20 str1
, str2
, message
= strprep(str1
, str2
, message
)
22 filterresult
= filterfunction(str1
, str2
)
23 except checks
.SeriousFilterFailure
, e
:
25 except checks
.FilterFailure
, e
:
27 exc_message
= e
.args
[0]
28 filterresult
= exc_message
!= message
29 print exc_message
.encode('utf-8')
32 return not filterresult
34 def fails_serious(filterfunction
, str1
, str2
, message
=None):
35 """returns whether the given strings fail on the given test, handling only SeriousFilterFailures"""
36 str1
, str2
, message
= strprep(str1
, str2
, message
)
38 filterresult
= filterfunction(str1
, str2
)
39 except checks
.SeriousFilterFailure
, e
:
41 exc_message
= e
.args
[0]
42 filterresult
= exc_message
!= message
43 print exc_message
.encode('utf-8')
46 return not filterresult
50 """tests default setup and that checks aren't altered by other constructions"""
51 stdchecker
= checks
.StandardChecker()
52 assert stdchecker
.config
.varmatches
== []
53 mozillachecker
= checks
.MozillaChecker()
54 stdchecker
= checks
.StandardChecker()
55 assert stdchecker
.config
.varmatches
== []
58 """tests that the checkers can be constructed"""
59 stdchecker
= checks
.StandardChecker()
60 mozillachecker
= checks
.MozillaChecker()
61 ooochecker
= checks
.OpenOfficeChecker()
62 gnomechecker
= checks
.GnomeChecker()
63 kdechecker
= checks
.KdeChecker()
65 def test_accelerator_markers():
66 """test that we have the correct accelerator marker for the various default configs"""
67 stdchecker
= checks
.StandardChecker()
68 assert stdchecker
.config
.accelmarkers
== []
69 mozillachecker
= checks
.MozillaChecker()
70 assert mozillachecker
.config
.accelmarkers
== ["&"]
71 ooochecker
= checks
.OpenOfficeChecker()
72 assert ooochecker
.config
.accelmarkers
== ["~"]
73 gnomechecker
= checks
.GnomeChecker()
74 assert gnomechecker
.config
.accelmarkers
== ["_"]
75 kdechecker
= checks
.KdeChecker()
76 assert kdechecker
.config
.accelmarkers
== ["&"]
79 """test that our helpers can check for messages and that these error messages can contain Unicode"""
80 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(validchars
='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'))
81 assert fails(stdchecker
.validchars
, "Some unexpected characters", "©", "invalid chars: '©' (\\u00a9)")
82 stdchecker
= checks
.StandardChecker()
83 assert fails_serious(stdchecker
.escapes
, r
"A tab", r
"'n Ṱab\t", r
"""escapes in original () don't match escapes in translation ('Ṱab\t')""")
85 def test_accelerators():
86 """tests accelerators"""
87 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(accelmarkers
="&"))
88 assert passes(stdchecker
.accelerators
, "&File", "&Fayile")
89 assert fails(stdchecker
.accelerators
, "&File", "Fayile")
90 assert fails(stdchecker
.accelerators
, "File", "&Fayile")
91 assert passes(stdchecker
.accelerators
, "Mail && News", "Pos en Nuus")
92 assert fails(stdchecker
.accelerators
, "Mail & News", "Pos en Nuus")
93 assert passes(stdchecker
.accelerators
, "&Allow", u
'&\ufeb2\ufee3\ufe8e\ufea3')
94 assert fails(stdchecker
.accelerators
, "Open &File", "Vula& Ifayile")
95 kdechecker
= checks
.KdeChecker()
96 assert passes(kdechecker
.accelerators
, "&File", "&Fayile")
97 assert fails(kdechecker
.accelerators
, "&File", "Fayile")
98 assert fails(kdechecker
.accelerators
, "File", "&Fayile")
99 gnomechecker
= checks
.GnomeChecker()
100 assert passes(gnomechecker
.accelerators
, "_File", "_Fayile")
101 assert fails(gnomechecker
.accelerators
, "_File", "Fayile")
102 assert fails(gnomechecker
.accelerators
, "File", "_Fayile")
103 mozillachecker
= checks
.MozillaChecker()
104 assert passes(mozillachecker
.accelerators
, "&File", "&Fayile")
105 assert fails_serious(mozillachecker
.accelerators
, "&File", "Fayile")
106 assert fails_serious(mozillachecker
.accelerators
, "File", "&Fayile")
107 assert passes(mozillachecker
.accelerators
, "Mail & News", "Pos en Nuus")
108 assert fails_serious(mozillachecker
.accelerators
, "Mail & News", "Pos en &Nuus")
109 assert fails_serious(mozillachecker
.accelerators
, "&File", "Fayile")
110 ooochecker
= checks
.OpenOfficeChecker()
111 assert passes(ooochecker
.accelerators
, "~File", "~Fayile")
112 assert fails(ooochecker
.accelerators
, "~File", "Fayile")
113 assert fails(ooochecker
.accelerators
, "File", "~Fayile")
115 # We don't want an accelerator for letters with a diacritic
116 assert fails(ooochecker
.accelerators
, "F~ile", "L~êer")
117 # Bug 289: accept accented accelerator characters
118 afchecker
= checks
.StandardChecker(checks
.CheckerConfig(accelmarkers
="&", targetlanguage
="fi"))
119 assert passes(afchecker
.accelerators
, "&Reload Frame", "P&äivitä kehys")
121 # Accelerator before variable - see test_acceleratedvariables
123 def xtest_acceleratedvariables():
124 """test for accelerated variables"""
125 # FIXME: disabled since acceleratedvariables has been removed, but these checks are still needed
126 mozillachecker
= checks
.MozillaChecker()
127 assert fails(mozillachecker
.acceleratedvariables
, "%S &Options", "&%S Ikhetho")
128 assert passes(mozillachecker
.acceleratedvariables
, "%S &Options", "%S &Ikhetho")
129 ooochecker
= checks
.OpenOfficeChecker()
130 assert fails(ooochecker
.acceleratedvariables
, "%PRODUCTNAME% ~Options", "~%PRODUCTNAME% Ikhetho")
131 assert passes(ooochecker
.acceleratedvariables
, "%PRODUCTNAME% ~Options", "%PRODUCTNAME% ~Ikhetho")
136 stdchecker
= checks
.StandardChecker()
137 assert passes(stdchecker
.acronyms
, "An HTML file", "'n HTML leer")
138 assert fails(stdchecker
.acronyms
, "An HTML file", "'n LMTH leer")
139 assert passes(stdchecker
.acronyms
, "It is HTML.", "Dit is HTML.")
140 # We don't mind if you add an acronym to correct bad capitalisation in the original
141 assert passes(stdchecker
.acronyms
, "An html file", "'n HTML leer")
142 # We shouldn't worry about acronyms that appear in a musttranslate file
143 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(musttranslatewords
=["OK"]))
144 assert passes(stdchecker
.acronyms
, "OK", "Kulungile")
145 # Assert punctuation should not hide accronyms
146 assert fails(stdchecker
.acronyms
, "Location (URL) not found", "Blah blah blah")
147 # Test '-W' (bug 283)
148 assert passes(stdchecker
.acronyms
, "%s: option `-W %s' is ambiguous", "%s: opsie '-W %s' is dubbelsinnig")
152 stdchecker
= checks
.StandardChecker()
153 assert fails(stdchecker
.blank
, "Save as", " ")
154 assert fails(stdchecker
.blank
, "_: KDE comment\\n\nSimple string", " ")
158 stdchecker
= checks
.StandardChecker()
159 assert passes(stdchecker
.brackets
, "N number(s)", "N getal(le)")
160 assert fails(stdchecker
.brackets
, "For {sic} numbers", "Vier getalle")
161 assert fails(stdchecker
.brackets
, "For }sic{ numbers", "Vier getalle")
162 assert fails(stdchecker
.brackets
, "For [sic] numbers", "Vier getalle")
163 assert fails(stdchecker
.brackets
, "For ]sic[ numbers", "Vier getalle")
164 assert passes(stdchecker
.brackets
, "{[(", "[({")
166 def test_compendiumconflicts():
167 """tests compendiumconflicts"""
168 stdchecker
= checks
.StandardChecker()
169 assert fails(stdchecker
.compendiumconflicts
, "File not saved", r
"""#-#-#-#-# file1.po #-#-#-#-#\n
170 Leer nie gestoor gestoor nie\n
171 #-#-#-#-# file1.po #-#-#-#-#\n
174 def test_doublequoting():
175 """tests double quotes"""
176 stdchecker
= checks
.StandardChecker()
177 assert fails(stdchecker
.doublequoting
, "Hot plate", "\"Ipuleti\" elishisa")
178 assert passes(stdchecker
.doublequoting
, "\"Hot\" plate", "\"Ipuleti\" elishisa")
179 assert fails(stdchecker
.doublequoting
, "'Hot' plate", "\"Ipuleti\" elishisa")
180 assert passes(stdchecker
.doublequoting
, "\\\"Hot\\\" plate", "\\\"Ipuleti\\\" elishisa")
182 # We don't want the filter to complain about "untranslated" quotes in xml attributes
183 frchecker
= checks
.StandardChecker(checks
.CheckerConfig(targetlanguage
="fr"))
184 assert passes(frchecker
.doublequoting
, "Click <a href=\"page.html\">", "Clique <a href=\"page.html\">")
185 assert fails(frchecker
.doublequoting
, "Do \"this\"", "Do \"this\"")
186 assert passes(frchecker
.doublequoting
, "Do \"this\"", "Do « this »")
187 assert fails(frchecker
.doublequoting
, "Do \"this\"", "Do « this » « this »")
189 vichecker
= checks
.StandardChecker(checks
.CheckerConfig(targetlanguage
="vi"))
190 assert passes(vichecker
.doublequoting
, 'Save "File"', u
"Lưu « Tập tin »")
192 def test_doublespacing():
193 """tests double spacing"""
194 stdchecker
= checks
.StandardChecker()
195 assert passes(stdchecker
.doublespacing
, "Sentence. Another sentence.", "Sin. 'n Ander sin.")
196 assert passes(stdchecker
.doublespacing
, "Sentence. Another sentence.", "Sin. No double spacing.")
197 assert fails(stdchecker
.doublespacing
, "Sentence. Another sentence.", "Sin. Missing the double space.")
198 assert fails(stdchecker
.doublespacing
, "Sentence. Another sentence.", "Sin. Uneeded double space in translation.")
199 ooochecker
= checks
.OpenOfficeChecker()
200 assert passes(ooochecker
.doublespacing
, "Execute %PROGRAMNAME Calc", "Blah %PROGRAMNAME Calc")
201 assert passes(ooochecker
.doublespacing
, "Execute %PROGRAMNAME Calc", "Blah % PROGRAMNAME Calc")
203 def test_doublewords():
204 """tests doublewords"""
205 stdchecker
= checks
.StandardChecker()
206 assert passes(stdchecker
.doublewords
, "Save the rhino", "Save the rhino")
207 assert fails(stdchecker
.doublewords
, "Save the rhino", "Save the the rhino")
208 # Double variables are not an error
209 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(varmatches
=[("%", 1)]))
210 assert passes(stdchecker
.doublewords
, "%s %s installation", "tsenyo ya %s %s")
214 stdchecker
= checks
.StandardChecker()
215 assert passes(stdchecker
.endpunc
, "Question?", "Correct?")
216 assert fails(stdchecker
.endpunc
, " Question?", "Wrong ?")
217 # Newlines must not mask end punctuation
218 assert fails(stdchecker
.endpunc
, "Exit change recording mode?\n\n", "Phuma esimeni sekugucula kubhalisa.\n\n")
219 mozillachecker
= checks
.MozillaChecker()
220 assert passes(mozillachecker
.endpunc
, "Upgrades an existing $ProductShortName$ installation.", "Ku antswisiwa ka ku nghenisiwa ka $ProductShortName$.")
222 assert passes(stdchecker
.endpunc
, "A nickname that identifies this publishing site (e.g.: 'MySite')", "Vito ro duvulela leri tirhisiwaka ku kuma sayiti leri ro kandziyisa (xik.: 'Sayiti ra Mina')")
223 assert fails(stdchecker
.endpunc
, "Question", u
"Wrong\u2026")
224 # Making sure singlequotes don't confuse things
225 assert passes(stdchecker
.endpunc
, "Pseudo-elements can't be negated '%1$S'.", "Pseudo-elemente kan nie '%1$S' ontken word nie.")
227 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(targetlanguage
='km'))
228 assert passes(stdchecker
.endpunc
, "In this new version, there are some minor conversion improvements on complex style in Openoffice.org Writer.", u
"នៅក្នុងកំណែថ្មីនេះ មានការកែសម្រួលមួយចំនួនតូចទាក់ទងនឹងការបំលែងពុម្ពអក្សរខ្មែរ ក្នុងកម្មវិធីការិយាល័យ ស្លឹករឹត ដែលមានប្រើប្រាស់រចនាប័ទ្មស្មុគស្មាញច្រើន\u00a0។")
230 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(targetlanguage
='zh'))
231 assert passes(stdchecker
.endpunc
, "To activate your account, follow this link:\n", u
"要啟用戶口,請瀏覽這個鏈結:\n")
233 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(targetlanguage
='vi'))
234 assert passes(stdchecker
.endpunc
, "Do you want to delete the XX dialog?", u
"Bạn có muốn xoá hộp thoại XX không?")
236 def test_endwhitespace():
237 """tests endwhitespace"""
238 stdchecker
= checks
.StandardChecker()
239 assert passes(stdchecker
.endwhitespace
, "A setence. ", "I'm correct. ")
240 assert fails(stdchecker
.endwhitespace
, "A setence. ", "'I'm incorrect.")
244 stdchecker
= checks
.StandardChecker()
245 assert passes(stdchecker
.escapes
, r
"""A sentence""", "I'm correct.")
246 assert passes(stdchecker
.escapes
, "A file\n", "'n Leer\n")
247 assert fails_serious(stdchecker
.escapes
, r
"blah. A file", r
"bleah.\n'n leer")
248 assert passes(stdchecker
.escapes
, r
"A tab\t", r
"'n Tab\t")
249 assert fails_serious(stdchecker
.escapes
, r
"A tab\t", r
"'n Tab")
250 assert passes(stdchecker
.escapes
, r
"An escape escape \\", r
"Escape escape \\")
251 assert fails_serious(stdchecker
.escapes
, r
"An escape escape \\", "Escape escape")
252 assert passes(stdchecker
.escapes
, r
"A double quote \"", r"Double quote
\"")
253 assert fails_serious(stdchecker.escapes, r"A double quote
\"", "Double quote
")
255 assert passes(stdchecker.escapes, "An escaped newline
\\n
", "Escaped newline
\\n
")
256 assert fails_serious(stdchecker.escapes, "An escaped newline
\\n
", "Escaped newline
\n")
258 ooochecker = checks.OpenOfficeChecker()
259 assert passes(ooochecker.escapes, ",\t44\t;\t59\t:\t58\t{Tab}
\t9\t{space}
\t32", ",\t44\t;\t59\t:\t58\t{Tab}
\t9\t{space}
\t32")
263 stdchecker = checks.StandardChecker()
264 assert passes(stdchecker.newlines, "Nothing to see
", "Niks te sien
")
265 assert passes(stdchecker.newlines, "Correct
\n", "Korrek
\n")
266 assert passes(stdchecker.newlines, "Correct
\r", "Korrek
\r")
267 assert passes(stdchecker.newlines, "Correct
\r\n", "Korrek
\r\n")
268 assert fails(stdchecker.newlines, "A
file\n", "'n Leer")
269 assert fails(stdchecker.newlines, "A file", "'n Leer
\n")
270 assert fails(stdchecker.newlines, "A
file\r", "'n Leer")
271 assert fails(stdchecker.newlines, "A file", "'n Leer
\r")
272 assert fails(stdchecker.newlines, "A
file\n", "'n Leer\r\n")
273 assert fails(stdchecker.newlines, "A file\r\n", "'n Leer
\n")
274 assert fails(stdchecker.newlines, "blah
.\nA
file", "bleah
. 'n leer")
276 ooochecker = checks.OpenOfficeChecker()
277 assert fails(ooochecker.newlines, "The arrowhead was modified without saving.\nWould you like to save the arrowhead now?", "Ṱhoho ya musevhe yo khwinifhadzwa hu si na u seiva.Ni khou ṱoda u seiva thoho ya musevhe zwino?")
281 stdchecker = checks.StandardChecker()
282 assert passes(stdchecker.tabs, "Nothing to see", "Niks te sien")
283 assert passes(stdchecker.tabs, "Correct\t", "Korrek\t")
284 assert passes(stdchecker.tabs, "Correct\tAA", "Korrek\tAA")
285 assert fails_serious(stdchecker.tabs, "A file\t", "'n Leer
")
286 assert fails_serious(stdchecker.tabs, "A
file", "'n Leer\t")
287 ooochecker = checks.OpenOfficeChecker()
288 assert passes(ooochecker.tabs, ",\t44\t;\t59\t:\t58\t{Tab}\t9\t{space}\t32", ",\t44\t;\t59\t:\t58\t{Tab}\t9\t{space}\t32")
290 def test_filepaths():
291 """tests filepaths"""
292 stdchecker = checks.StandardChecker()
293 assert passes(stdchecker.filepaths, "%s to the file /etc/hosts on your system.", "%s na die leer /etc/hosts op jou systeem.")
294 assert fails(stdchecker.filepaths, "%s to the file /etc/hosts on your system.", "%s na die leer /etc/gasheer op jou systeem.")
296 def test_kdecomments():
297 """tests kdecomments"""
298 stdchecker = checks.StandardChecker()
299 assert passes(stdchecker.kdecomments, r"""_: I am a comment\n
300 A string to translate""", "'n String om te vertaal
")
301 assert fails(stdchecker.kdecomments, r"""_: I am a comment\n
302 A string to translate""", r"""_: Ek is 'n commment\n
303 'n String om te vertaal""")
304 assert fails(stdchecker.kdecomments, """_: I am a comment\\n\n""", """_: I am a comment\\n\n""")
307 """tests long messages"""
308 stdchecker = checks.StandardChecker()
309 assert passes(stdchecker.long, "I am normal
", "Ek
is ook normaal
")
310 assert fails(stdchecker.long, "Short
.", "Kort
.......................................................................................")
311 assert fails(stdchecker.long, "a
", "bc
")
313 def test_musttranslatewords():
314 """tests stopwords"""
315 stdchecker = checks.StandardChecker(checks.CheckerConfig(musttranslatewords=[]))
316 assert passes(stdchecker.musttranslatewords, "This uses Mozilla of course
", "hierdie gebruik le mozille natuurlik
")
317 stdchecker = checks.StandardChecker(checks.CheckerConfig(musttranslatewords=["Mozilla
"]))
318 assert passes(stdchecker.musttranslatewords, "This uses Mozilla of course
", "hierdie gebruik le mozille natuurlik
")
319 assert fails(stdchecker.musttranslatewords, "This uses Mozilla of course
", "hierdie gebruik Mozilla natuurlik
")
320 assert passes(stdchecker.musttranslatewords, "This uses Mozilla
. Don
't you?", "hierdie gebruik le mozille soos jy")
321 assert fails(stdchecker.musttranslatewords, "This uses Mozilla. Don't you?
", "hierdie gebruik Mozilla soos jy
")
322 # should always pass if there are no stopwords in the original
323 assert passes(stdchecker.musttranslatewords, "This uses something
else. Don
't you?", "hierdie gebruik Mozilla soos jy")
324 # check that we can find words surrounded by punctuation
325 assert passes(stdchecker.musttranslatewords, "Click 'Mozilla
' button", "Kliek 'Motzille
' knoppie")
326 assert fails(stdchecker.musttranslatewords, "Click 'Mozilla
' button", "Kliek 'Mozilla
' knoppie")
327 assert passes(stdchecker.musttranslatewords, 'Click
"Mozilla" button
', 'Kliek
"Motzille" knoppie
')
328 assert fails(stdchecker.musttranslatewords, 'Click
"Mozilla" button
', 'Kliek
"Mozilla" knoppie
')
329 assert fails(stdchecker.musttranslatewords, 'Click
"Mozilla" button
', u'Kliek «Mozilla» knoppie
')
330 assert passes(stdchecker.musttranslatewords, "Click (Mozilla) button", "Kliek (Motzille) knoppie")
331 assert fails(stdchecker.musttranslatewords, "Click (Mozilla) button", "Kliek (Mozilla) knoppie")
332 assert passes(stdchecker.musttranslatewords, "Click Mozilla!", "Kliek Motzille!")
333 assert fails(stdchecker.musttranslatewords, "Click Mozilla!", "Kliek Mozilla!")
334 ## We need to define more word separators to allow us to find those hidden untranslated items
335 #assert fails(stdchecker.musttranslatewords, "Click OK", "Blah we-OK")
336 # Don't get confused when variables are the same
as a musttranslate word
337 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(varmatches
=[("%", None), ], musttranslatewords
=["OK"]))
338 assert passes(stdchecker
.musttranslatewords
, "Click %OK to start", "Kliek %OK om te begin")
340 assert fails(stdchecker
.musttranslatewords
, "Click OK", u
"Kiḽikani OK")
342 def test_notranslatewords():
343 """tests stopwords"""
344 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(notranslatewords
=[]))
345 assert passes(stdchecker
.notranslatewords
, "This uses Mozilla of course", "hierdie gebruik le mozille natuurlik")
346 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(notranslatewords
=["Mozilla", "Opera"]))
347 assert fails(stdchecker
.notranslatewords
, "This uses Mozilla of course", "hierdie gebruik le mozille natuurlik")
348 assert passes(stdchecker
.notranslatewords
, "This uses Mozilla of course", "hierdie gebruik Mozilla natuurlik")
349 assert fails(stdchecker
.notranslatewords
, "This uses Mozilla. Don't you?", "hierdie gebruik le mozille soos jy")
350 assert passes(stdchecker
.notranslatewords
, "This uses Mozilla. Don't you?", "hierdie gebruik Mozilla soos jy")
351 # should always pass if there are no stopwords in the original
352 assert passes(stdchecker
.notranslatewords
, "This uses something else. Don't you?", "hierdie gebruik Mozilla soos jy")
354 assert passes(stdchecker
.notranslatewords
, "using Mozilla Task Manager", u
"šomiša Selaola Mošomo sa Mozilla, gomme")
355 # Find words even if they are embedded in punctuation
356 assert fails(stdchecker
.notranslatewords
, "Click 'Mozilla' button", "Kliek 'Motzille' knoppie")
357 assert passes(stdchecker
.notranslatewords
, "Click 'Mozilla' button", "Kliek 'Mozilla' knoppie")
358 assert fails(stdchecker
.notranslatewords
, "Click Mozilla!", "Kliek Motzille!")
359 assert passes(stdchecker
.notranslatewords
, "Click Mozilla!", "Kliek Mozilla!")
360 assert fails(stdchecker
.notranslatewords
, "Searches (From Opera)", "adosako (kusukela ku- Ophera)")
361 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(notranslatewords
=["Sun", "NeXT"]))
362 assert fails(stdchecker
.notranslatewords
, "Sun/NeXT Audio", "Odio dza Ḓuvha/TeVHELAHO")
363 assert passes(stdchecker
.notranslatewords
, "Sun/NeXT Audio", "Odio dza Sun/NeXT")
364 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(notranslatewords
=["sendmail"]))
365 assert fails(stdchecker
.notranslatewords
, "because 'sendmail' could", "ngauri 'rumelameiḽi' a yo")
366 assert passes(stdchecker
.notranslatewords
, "because 'sendmail' could", "ngauri 'sendmail' a yo")
367 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(notranslatewords
=["Base"]))
368 assert fails(stdchecker
.notranslatewords
, " - %PRODUCTNAME Base: Relation design", " - %PRODUCTNAME Sisekelo: Umsiko wekuhlobana")
369 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(notranslatewords
=["Writer"]))
370 assert fails(stdchecker
.notranslatewords
, "&[ProductName] Writer/Web", "&[ProductName] Umbhali/iWebhu")
371 # Unicode - different decompositions
372 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(notranslatewords
=[u
"\u1e3cike"]))
373 assert passes(stdchecker
.notranslatewords
, u
"You \u1e3cike me", u
"Ek \u004c\u032dike jou")
377 stdchecker
= checks
.StandardChecker()
378 assert passes(stdchecker
.numbers
, "Netscape 4 was not as good as Netscape 7.", "Netscape 4 was nie so goed soos Netscape 7 nie.")
379 # Check for correct detection of degree. Also check that we aren't getting confused with 1 and 2 byte UTF-8 characters
380 assert fails(stdchecker
.numbers
, "180° turn", "180 turn")
381 assert passes(stdchecker
.numbers
, "180° turn", "180° turn")
382 assert fails(stdchecker
.numbers
, "180° turn", "360 turn")
383 assert fails(stdchecker
.numbers
, "180° turn", "360° turn")
384 assert passes(stdchecker
.numbers
, "180~ turn", "180 turn")
385 assert passes(stdchecker
.numbers
, "180¶ turn", "180 turn")
386 # Numbers with multiple decimal points
387 assert passes(stdchecker
.numbers
, "12.34.56", "12.34.56")
388 assert fails(stdchecker
.numbers
, "12.34.56", "98.76.54")
390 # FIXME we should probably be able to handle currency checking with locale inteligence
391 assert passes(stdchecker
.numbers
, "R57.60", "R57.60")
392 # FIXME - again locale intelligence should allow us to use other decimal seperators
393 assert fails(stdchecker
.numbers
, "R57.60", "R57,60")
394 assert fails(stdchecker
.numbers
, "1,000.00", "1 000,00")
395 # You should be able to reorder numbers
396 assert passes(stdchecker
.numbers
, "40-bit RC2 encryption with RSA and an MD5", "Umbhalo ocashile i-RC2 onamabhithi angu-40 one-RSA ne-MD5")
399 """tests command line options e.g. --option"""
400 stdchecker
= checks
.StandardChecker()
401 assert passes(stdchecker
.options
, "--help", "--help")
402 assert fails(stdchecker
.options
, "--help", "--hulp")
403 assert fails(stdchecker
.options
, "--input=FILE", "--input=FILE")
404 assert passes(stdchecker
.options
, "--input=FILE", "--input=LÊER")
405 assert fails(stdchecker
.options
, "--input=FILE", "--tovoer=LÊER")
406 # We don't want just any '--' to trigger this test - the error will be confusing
407 assert passes(stdchecker
.options
, "Hello! -- Hi", "Hallo! — Haai")
408 assert passes(stdchecker
.options
, "--blank--", "--vide--")
411 """tests printf style variables"""
412 # This should really be a subset of the variable checks
413 # Ideally we should be able to adapt based on #, directives also
414 stdchecker
= checks
.StandardChecker()
415 assert passes(stdchecker
.printf
, "I am %s", "Ek is %s")
416 assert fails(stdchecker
.printf
, "I am %s", "Ek is %d")
417 assert passes(stdchecker
.printf
, "I am %#100.50hhf", "Ek is %#100.50hhf")
418 assert fails(stdchecker
.printf
, "I am %#100s", "Ek is %10s")
419 assert fails(stdchecker
.printf
, "... for user %.100s on %.100s:", "... lomuntu osebenzisa i-%. I-100s e-100s:")
420 assert passes(stdchecker
.printf
, "%dMB", "%d MG")
422 assert passes(stdchecker
.printf
, "String %s and number %d", "String %1$s en nommer %2$d")
423 assert passes(stdchecker
.printf
, "String %1$s and number %2$d", "String %1$s en nommer %2$d")
424 assert passes(stdchecker
.printf
, "String %s and number %d", "Nommer %2$d and string %1$s")
425 assert fails(stdchecker
.printf
, "String %s and number %d", "Nommer %1$d and string %2$s")
427 def test_puncspacing():
428 """tests spacing after punctuation"""
429 stdchecker
= checks
.StandardChecker()
430 assert passes(stdchecker
.puncspacing
, "One, two, three.", "Kunye, kubili, kuthathu.")
431 assert passes(stdchecker
.puncspacing
, "One, two, three. ", "Kunye, kubili, kuthathu.")
432 assert fails(stdchecker
.puncspacing
, "One, two, three. ", "Kunye, kubili,kuthathu.")
433 assert passes(stdchecker
.puncspacing
, "One, two, three!?", "Kunye, kubili, kuthathu?")
435 # Some languages have padded puntuation marks
436 frchecker
= checks
.StandardChecker(checks
.CheckerConfig(targetlanguage
="fr"))
437 assert passes(frchecker
.puncspacing
, "Do \"this\"", "Do « this »")
438 assert fails(frchecker
.puncspacing
, "Do \"this\"", "Do «this»")
441 """tests messages containing only punctuation"""
442 stdchecker
= checks
.StandardChecker()
443 assert passes(stdchecker
.purepunc
, ".", ".")
444 assert passes(stdchecker
.purepunc
, "", "")
445 assert fails(stdchecker
.purepunc
, ".", " ")
446 assert fails(stdchecker
.purepunc
, "Find", "'")
447 assert fails(stdchecker
.purepunc
, "'", "Find")
449 def test_sentencecount():
450 """tests sentencecount messages"""
451 stdchecker
= checks
.StandardChecker()
452 assert passes(stdchecker
.sentencecount
, "One. Two. Three.", "Een. Twee. Drie.")
453 assert passes(stdchecker
.sentencecount
, "One two three", "Een twee drie.")
454 assert fails(stdchecker
.sentencecount
, "One. Two. Three.", "Een Twee. Drie.")
455 assert passes(stdchecker
.sentencecount
, "Sentence with i.e. in it.", "Sin met d.w.s. in dit.") # bug 178, description item 8
458 """tests short messages"""
459 stdchecker
= checks
.StandardChecker()
460 assert passes(stdchecker
.short
, "I am normal", "Ek is ook normaal")
461 assert fails(stdchecker
.short
, "I am a very long sentence", "Ek")
462 assert fails(stdchecker
.short
, "abcde", "c")
464 def test_singlequoting():
465 """tests single quotes"""
466 stdchecker
= checks
.StandardChecker()
467 assert passes(stdchecker
.singlequoting
, "A 'Hot' plate", "Ipuleti 'elishisa' kunye")
468 # FIXME this should pass but doesn't probably to do with our logic that got confused at the end of lines
469 assert passes(stdchecker
.singlequoting
, "'Hot' plate", "Ipuleti 'elishisa'")
470 # FIXME newlines also confuse our algorithm for single quotes
471 assert passes(stdchecker
.singlequoting
, "File '%s'\n", "'%s' Faele\n")
472 assert fails(stdchecker
.singlequoting
, "'Hot' plate", "Ipuleti \"elishisa\"")
473 assert passes(stdchecker
.singlequoting
, "It's here.", "Dit is hier.")
474 # Don't get confused by punctuation that touches a single quote
475 assert passes(stdchecker
.singlequoting
, "File '%s'.", "'%s' Faele.")
476 assert passes(stdchecker
.singlequoting
, "Blah 'format' blah.", "Blah blah 'sebopego'.")
477 assert passes(stdchecker
.singlequoting
, "Blah 'format' blah!", "Blah blah 'sebopego'!")
478 assert passes(stdchecker
.singlequoting
, "Blah 'format' blah?", "Blah blah 'sebopego'?")
480 assert passes(stdchecker
.singlequoting
, "A nickname that identifies this publishing site (e.g.: 'MySite')", "Vito ro duvulela leri tirhisiwaka ku kuma sayiti leri ro kandziyisa (xik.: 'Sayiti ra Mina')")
481 assert passes(stdchecker
.singlequoting
, "isn't", "ayikho")
482 assert passes(stdchecker
.singlequoting
, "Required (can't send message unless all recipients have certificates)", "Verlang (kan nie boodskappe versend tensy al die ontvangers sertifikate het nie)")
484 assert passes(stdchecker
.singlequoting
, "Please enter a different site name.", "Tik 'n ander werfnaam in.")
485 assert passes(stdchecker
.singlequoting
, "\"%name%\" already exists. Please enter a different site name.", "\"%name%\" bestaan reeds. Tik 'n ander werfnaam in.")
486 # Check that accelerators don't mess with removing singlequotes
487 mozillachecker
= checks
.MozillaChecker()
488 assert passes(mozillachecker
.singlequoting
, "&Don't import anything", "&Moenie enigiets invoer nie")
489 ooochecker
= checks
.OpenOfficeChecker()
490 assert passes(ooochecker
.singlequoting
, "~Don't import anything", "~Moenie enigiets invoer nie")
492 vichecker
= checks
.StandardChecker(checks
.CheckerConfig(targetlanguage
="vi"))
493 assert passes(vichecker
.doublequoting
, "Save 'File'", u
"Lưu « Tập tin »")
494 assert passes(vichecker
.doublequoting
, "Save `File'", u
"Lưu « Tập tin »")
496 def test_simplecaps():
497 """tests simple caps"""
498 # Simple caps is a very vauge test so the checks here are mostly for obviously fixable problem
499 # or for checking obviously correct situations that are triggering a failure.
500 stdchecker
= checks
.StandardChecker()
501 assert passes(stdchecker
.simplecaps
, "MB of disk space for the cache.", "MB yendzawo yediski etsala.")
502 # We should squash 'I' in the source text as it messes with capital detection
503 assert passes(stdchecker
.simplecaps
, "if you say I want", "as jy se ek wil")
504 assert passes(stdchecker
.simplecaps
, "sentence. I want more.", "sin. Ek wil meer he.")
505 assert passes(stdchecker
.simplecaps
, "Where are we? I can't see where we are going.", "Waar is ons? Ek kan nie sien waar ons gaan nie.")
506 ## We should remove variables before checking
507 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(varmatches
=[("%", 1)]))
508 assert passes(stdchecker
.simplecaps
, "Could not load %s", "A swi koteki ku panga %S")
509 assert passes(stdchecker
.simplecaps
, "The element \"%S\" is not recognized.", "Elemente \"%S\" a yi tiveki.")
510 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(varmatches
=[("&", ";")]))
511 assert passes(stdchecker
.simplecaps
, "Determine how &brandShortName; connects to the Internet.", "Kuma &brandShortName; hlanganisa eka Internete.")
512 ## If source is ALL CAPS then we should just check that target is also ALL CAPS
513 assert passes(stdchecker
.simplecaps
, "COUPDAYS", "COUPMALANGA")
514 # Just some that at times have failed but should always pass
515 assert passes(stdchecker
.simplecaps
, "Create a query entering an SQL statement directly.", "Yakha sibuti singena SQL inkhomba yesitatimende.")
516 ooochecker
= checks
.OpenOfficeChecker()
517 assert passes(ooochecker
.simplecaps
, "SOLK (%PRODUCTNAME Link)", "SOLK (%PRODUCTNAME Thumanyo)")
518 assert passes(ooochecker
.simplecaps
, "%STAROFFICE Image", "Tshifanyiso tsha %STAROFFICE")
519 assert passes(stdchecker
.simplecaps
, "Flies, flies, everywhere! Ack!", u
"Vlieë, oral vlieë! Jig!")
521 def test_spellcheck():
522 """tests spell checking"""
523 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(targetlanguage
="af"))
524 assert passes(stdchecker
.spellcheck
, "Great trek", "Groot trek")
525 assert fails(stdchecker
.spellcheck
, "Final deadline", "End of the road")
526 # Bug 289: filters accelerators before spell checking
527 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(accelmarkers
="&", targetlanguage
="fi"))
528 assert passes(stdchecker
.spellcheck
, "&Reload Frame", "P&äivitä kehys")
529 # Ensure we don't check notranslatewords
530 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(targetlanguage
="af"))
531 assert fails(stdchecker
.spellcheck
, "Mozilla is wonderful", "Mozilla is wonderlik")
532 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(targetlanguage
="af", notranslatewords
=["Mozilla"]))
533 assert passes(stdchecker
.spellcheck
, "Mozilla is wonderful", "Mozilla is wonderlik")
535 def test_startcaps():
536 """tests starting capitals"""
537 stdchecker
= checks
.StandardChecker()
538 assert passes(stdchecker
.startcaps
, "Find", "Vind")
539 assert passes(stdchecker
.startcaps
, "find", "vind")
540 assert fails(stdchecker
.startcaps
, "Find", "vind")
541 assert fails(stdchecker
.startcaps
, "find", "Vind")
542 assert passes(stdchecker
.startcaps
, "'", "'")
543 assert passes(stdchecker
.startcaps
, "\\.,/?!`'\"[]{}()@#$%^&*_-;:<>Find", "\\.,/?!`'\"[]{}()@#$%^&*_-;:<>Vind")
544 # With leading whitespace
545 assert passes(stdchecker
.startcaps
, " Find", " Vind")
546 assert passes(stdchecker
.startcaps
, " find", " vind")
547 assert fails(stdchecker
.startcaps
, " Find", " vind")
548 assert fails(stdchecker
.startcaps
, " find", " Vind")
549 # Leading punctuation
550 assert passes(stdchecker
.startcaps
, "'Find", "'Vind")
551 assert passes(stdchecker
.startcaps
, "'find", "'vind")
552 assert fails(stdchecker
.startcaps
, "'Find", "'vind")
553 assert fails(stdchecker
.startcaps
, "'find", "'Vind")
555 assert passes(stdchecker
.startcaps
, "Find", u
"Šind")
556 assert passes(stdchecker
.startcaps
, "find", u
"šind")
557 assert fails(stdchecker
.startcaps
, "Find", u
"šind")
558 assert fails(stdchecker
.startcaps
, "find", u
"Šind")
559 # Unicode further down the Unicode tables
560 assert passes(stdchecker
.startcaps
, "A text enclosed...", u
"Ḽiṅwalwa ḽo katelwaho...")
561 assert fails(stdchecker
.startcaps
, "A text enclosed...", u
"ḽiṅwalwa ḽo katelwaho...")
564 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(accelmarkers
="&"))
565 assert passes(stdchecker
.startcaps
, "&Find", "Vi&nd")
567 # Language specific stuff
568 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(targetlanguage
='af'))
569 assert passes(stdchecker
.startcaps
, "A cow", "'n Koei")
570 assert passes(stdchecker
.startcaps
, "A list of ", "'n Lys van ")
572 #assert passes(stdchecker.startcaps, "A 1k file", u"'n 1k-lêer")
573 assert passes(stdchecker
.startcaps
, "'Do it'", "'Doen dit'")
574 assert fails(stdchecker
.startcaps
, "'Closer than'", "'nader as'")
575 assert passes(stdchecker
.startcaps
, "List", "Lys")
576 assert passes(stdchecker
.startcaps
, "a cow", "'n koei")
577 assert fails(stdchecker
.startcaps
, "a cow", "'n Koei")
578 assert passes(stdchecker
.startcaps
, "(A cow)", "('n Koei)")
579 assert fails(stdchecker
.startcaps
, "(a cow)", "('n Koei)")
581 def test_startpunc():
582 """tests startpunc"""
583 stdchecker
= checks
.StandardChecker()
584 assert passes(stdchecker
.startpunc
, "<< Previous", "<< Correct")
585 assert fails(stdchecker
.startpunc
, " << Previous", "Wrong")
586 assert fails(stdchecker
.startpunc
, "Question", u
"\u2026Wrong")
588 def test_startwhitespace():
589 """tests startwhitespace"""
590 stdchecker
= checks
.StandardChecker()
591 assert passes(stdchecker
.startwhitespace
, "A setence.", "I'm correct.")
592 assert fails(stdchecker
.startwhitespace
, " A setence.", "I'm incorrect.")
594 def test_unchanged():
595 """tests unchanged entries"""
596 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(accelmarkers
="&"))
597 assert fails(stdchecker
.unchanged
, "Unchanged", "Unchanged")
598 assert fails(stdchecker
.unchanged
, "&Unchanged", "Un&changed")
599 assert passes(stdchecker
.unchanged
, "Unchanged", "Changed")
600 assert passes(stdchecker
.unchanged
, "1234", "1234")
601 assert passes(stdchecker
.unchanged
, "2×2", "2×2") # bug 178, description item 14
602 assert passes(stdchecker
.unchanged
, "I", "I")
603 assert passes(stdchecker
.unchanged
, " ", " ") # bug 178, description item 5
604 assert passes(stdchecker
.unchanged
, "???", "???") # bug 178, description item 15
605 assert passes(stdchecker
.unchanged
, "&ACRONYM", "&ACRONYM") # bug 178, description item 7
606 assert passes(stdchecker
.unchanged
, "F1", "F1") # bug 178, description item 20
607 # Variable only and variable plus punctuation messages should be ignored
608 mozillachecker
= checks
.MozillaChecker()
609 assert passes(mozillachecker
.unchanged
, "$ProgramName$", "$ProgramName$")
610 assert passes(mozillachecker
.unchanged
, "$file$ : $dir$", "$file$ : $dir$") # bug 178, description item 13
611 assert fails(mozillachecker
.unchanged
, "$file$ in $dir$", "$file$ in $dir$")
612 # Don't translate words should be ignored
613 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(notranslatewords
=["Mozilla"]))
614 assert passes(stdchecker
.unchanged
, "Mozilla", "Mozilla") # bug 178, description item 10
616 def test_untranslated():
617 """tests untranslated entries"""
618 stdchecker
= checks
.StandardChecker()
619 assert fails(stdchecker
.untranslated
, "I am untranslated", "")
620 assert passes(stdchecker
.untranslated
, "I am translated", "Ek is vertaal")
621 # KDE comments that make it into translations should not mask untranslated test
622 assert fails(stdchecker
.untranslated
, "_: KDE comment\\n\nI am untranslated", "_: KDE comment\\n\n")
624 def test_validchars():
625 """tests valid characters"""
626 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig())
627 assert passes(stdchecker
.validchars
, "The check always passes if you don't specify chars", "Die toets sal altyd werk as jy nie karacters specifisier")
628 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(validchars
='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'))
629 assert passes(stdchecker
.validchars
, "This sentence contains valid characters", "Hierdie sin bevat ware karakters")
630 assert fails(stdchecker
.validchars
, "Some unexpected characters", "©®°±÷¼½¾")
631 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(validchars
='⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰'))
632 assert passes(stdchecker
.validchars
, "Our target language is all non-ascii", "⠁⠂⠃⠄⠆⠇⠈⠉⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫")
633 assert fails(stdchecker
.validchars
, "Our target language is all non-ascii", "Some ascii⠁⠂⠃⠄⠆⠇⠈⠉⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫")
634 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(validchars
=u
'\u004c\u032d'))
635 assert passes(stdchecker
.validchars
, "This sentence contains valid chars", u
"\u004c\u032d")
636 assert passes(stdchecker
.validchars
, "This sentence contains valid chars", u
"\u1e3c")
637 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(validchars
=u
'\u1e3c'))
638 assert passes(stdchecker
.validchars
, "This sentence contains valid chars", u
"\u1e3c")
639 assert passes(stdchecker
.validchars
, "This sentence contains valid chars", u
"\u004c\u032d")
641 def test_variables_kde():
642 """tests variables in KDE translations"""
644 kdechecker
= checks
.KdeChecker()
645 assert passes(kdechecker
.variables
, "%d files of type %s saved.", "%d leers van %s tipe gestoor.")
646 assert fails_serious(kdechecker
.variables
, "%d files of type %s saved.", "%s leers van %s tipe gestoor.")
648 def test_variables_gnome():
649 """tests variables in GNOME translations"""
651 gnomechecker
= checks
.GnomeChecker()
652 assert passes(gnomechecker
.variables
, "%d files of type %s saved.", "%d leers van %s tipe gestoor.")
653 assert fails_serious(gnomechecker
.variables
, "%d files of type %s saved.", "%s leers van %s tipe gestoor.")
654 assert passes(gnomechecker
.variables
, "Save $(file)", "Stoor $(file)")
655 assert fails_serious(gnomechecker
.variables
, "Save $(file)", "Stoor $(leer)")
657 def test_variables_mozilla():
658 """tests variables in Mozilla translations"""
660 mozillachecker
= checks
.MozillaChecker()
661 assert passes(mozillachecker
.variables
, "Use the &brandShortname; instance.", "Gebruik die &brandShortname; weergawe.")
662 assert fails_serious(mozillachecker
.variables
, "Use the &brandShortname; instance.", "Gebruik die &brandKortnaam; weergawe.")
663 assert passes(mozillachecker
.variables
, "Save %file%", "Stoor %file%")
664 assert fails_serious(mozillachecker
.variables
, "Save %file%", "Stoor %leer%")
665 assert passes(mozillachecker
.variables
, "Save $file$", "Stoor $file$")
666 assert fails_serious(mozillachecker
.variables
, "Save $file$", "Stoor $leer$")
667 assert passes(mozillachecker
.variables
, "%d files of type %s saved.", "%d leers van %s tipe gestoor.")
668 assert fails_serious(mozillachecker
.variables
, "%d files of type %s saved.", "%s leers van %s tipe gestoor.")
669 assert passes(mozillachecker
.variables
, "Save $file", "Stoor $file")
670 assert fails_serious(mozillachecker
.variables
, "Save $file", "Stoor $leer")
671 assert passes(mozillachecker
.variables
, "About $ProgramName$", "Oor $ProgramName$")
672 assert fails_serious(mozillachecker
.variables
, "About $ProgramName$", "Oor $NaamVanProgam$")
673 assert passes(mozillachecker
.variables
, "About $_CLICK", "Oor $_CLICK")
674 assert fails_serious(mozillachecker
.variables
, "About $_CLICK", "Oor $_KLIK")
675 assert passes(mozillachecker
.variables
, "About $_CLICK and more", "Oor $_CLICK en meer")
676 assert fails_serious(mozillachecker
.variables
, "About $_CLICK and more", "Oor $_KLIK en meer")
677 assert passes(mozillachecker
.variables
, "About $(^NameDA)", "Oor $(^NameDA)")
678 assert fails_serious(mozillachecker
.variables
, "About $(^NameDA)", "Oor $(^NaamDA)")
679 # Double variable problem
680 assert fails_serious(mozillachecker
.variables
, "Create In <<", "Etsa ka Ho <lt;")
681 # Variables at the end of a sentence
682 assert fails_serious(mozillachecker
.variables
, "...time you start &brandShortName;.", "...lekgetlo le latelang ha o qala &LebitsoKgutshwane la kgwebo;.")
683 # Ensure that we can detect two variables of the same name with one faulty
684 assert fails_serious(mozillachecker
.variables
, "&brandShortName; successfully downloaded and installed updates. You will have to restart &brandShortName; to complete the update.", "&brandShortName; ḽo dzhenisa na u longela khwinifhadzo zwavhuḓi. Ni ḓo tea u thoma hafhu &DzinaḼipfufhi ḽa pfungavhuṇe; u itela u fhedzisa khwinifha dzo.")
685 # We must detect entities in their fullform, ie with fullstop in the middle.
686 assert fails_serious(mozillachecker
.variables
, "Welcome to the &pluginWizard.title;", "Wamkelekile kwi&Sihloko Soncedo lwe-plugin;")
687 # Variables that are missing in quotes should be detected
688 assert fails_serious(mozillachecker
.variables
, "\"%S\" is an executable file.... Are you sure you want to launch \"%S\"?", ".... Uyaqiniseka ukuthi ufuna ukuqalisa I\"%S\"?")
689 # False positive $ style variables
690 assert passes(mozillachecker
.variables
, "for reporting $ProductShortName$ crash information", "okokubika ukwaziswa kokumosheka kwe-$ProductShortName$")
691 # We shouldn't mask variables within variables. This should highlight &brandShortName as missing and & as extra
692 assert fails_serious(mozillachecker
.variables
, "&brandShortName;", "&brandShortName;")
694 def test_variables_openoffice():
695 """tests variables in OpenOffice translations"""
696 # OpenOffice.org variables
697 ooochecker
= checks
.OpenOfficeChecker()
698 assert passes(ooochecker
.variables
, "Use the &brandShortname; instance.", "Gebruik die &brandShortname; weergawe.")
699 assert fails_serious(ooochecker
.variables
, "Use the &brandShortname; instance.", "Gebruik die &brandKortnaam; weergawe.")
700 assert passes(ooochecker
.variables
, "Save %file%", "Stoor %file%")
701 assert fails_serious(ooochecker
.variables
, "Save %file%", "Stoor %leer%")
702 assert passes(ooochecker
.variables
, "Save %file", "Stoor %file")
703 assert fails_serious(ooochecker
.variables
, "Save %file", "Stoor %leer")
704 assert passes(ooochecker
.variables
, "Save %1", "Stoor %1")
705 assert fails_serious(ooochecker
.variables
, "Save %1", "Stoor %2")
706 assert passes(ooochecker
.variables
, "Save %", "Stoor %")
707 assert fails_serious(ooochecker
.variables
, "Save %", "Stoor")
708 assert passes(ooochecker
.variables
, "Save $(file)", "Stoor $(file)")
709 assert fails_serious(ooochecker
.variables
, "Save $(file)", "Stoor $(leer)")
710 assert passes(ooochecker
.variables
, "Save $file$", "Stoor $file$")
711 assert fails_serious(ooochecker
.variables
, "Save $file$", "Stoor $leer$")
712 assert passes(ooochecker
.variables
, "Save ${file}", "Stoor ${file}")
713 assert fails_serious(ooochecker
.variables
, "Save ${file}", "Stoor ${leer}")
714 assert passes(ooochecker
.variables
, "Save #file#", "Stoor #file#")
715 assert fails_serious(ooochecker
.variables
, "Save #file#", "Stoor #leer#")
716 assert passes(ooochecker
.variables
, "Save #1", "Stoor #1")
717 assert fails_serious(ooochecker
.variables
, "Save #1", "Stoor #2")
718 assert passes(ooochecker
.variables
, "Save #", "Stoor #")
719 assert fails_serious(ooochecker
.variables
, "Save #", "Stoor")
720 assert passes(ooochecker
.variables
, "Save ($file)", "Stoor ($file)")
721 assert fails_serious(ooochecker
.variables
, "Save ($file)", "Stoor ($leer)")
722 assert passes(ooochecker
.variables
, "Save $[file]", "Stoor $[file]")
723 assert fails_serious(ooochecker
.variables
, "Save $[file]", "Stoor $[leer]")
724 assert passes(ooochecker
.variables
, "Save [file]", "Stoor [file]")
725 assert fails_serious(ooochecker
.variables
, "Save [file]", "Stoor [leer]")
726 assert passes(ooochecker
.variables
, "Save $file", "Stoor $file")
727 assert fails_serious(ooochecker
.variables
, "Save $file", "Stoor $leer")
728 # Same variable name twice
729 assert fails_serious(ooochecker
.variables
, r
"""Start %PROGRAMNAME% as %PROGRAMNAME%""", "Begin %PROGRAMNAME%")
731 def test_variables_cclicense():
732 """Tests variables in Creative Commons translations."""
733 checker
= checks
.CCLicenseChecker()
734 assert passes(checker
.variables
, "CC-GNU @license_code@.", "CC-GNU @license_code@.")
735 assert fails_serious(checker
.variables
, "CC-GNU @license_code@.", "CC-GNU @lisensie_kode@.")
736 assert passes(checker
.variables
, "Deed to the @license_name_full@", "Akte vir die @license_name_full@")
737 assert fails_serious(checker
.variables
, "Deed to the @license_name_full@", "Akte vir die @volle_lisensie@")
738 assert passes(checker
.variables
, "The @license_name_full@ is", "Die @license_name_full@ is")
739 assert fails_serious(checker
.variables
, "The @license_name_full@ is", "Die @iiilicense_name_full@ is")
740 assert fails_serious(checker
.variables
, "A @ccvar@", "'n @ccvertaaldeveranderlike@")
744 stdchecker
= checks
.StandardChecker()
745 assert fails(stdchecker
.xmltags
, "Do it <b>now</b>", "Doen dit <v>nou</v>")
746 assert passes(stdchecker
.xmltags
, "Do it <b>now</b>", "Doen dit <b>nou</b>")
747 assert passes(stdchecker
.xmltags
, "Click <img src=\"img.jpg\">here</img>", "Klik <img src=\"img.jpg\">hier</img>")
748 assert fails(stdchecker
.xmltags
, "Click <img src=\"image.jpg\">here</img>", "Klik <img src=\"prent.jpg\">hier</img>")
749 assert passes(stdchecker
.xmltags
, "Click <img src=\"img.jpg\" alt=\"picture\">here</img>", "Klik <img src=\"img.jpg\" alt=\"prentjie\">hier</img>")
750 assert passes(stdchecker
.xmltags
, "Start with the <start> tag", "Begin met die <begin>")
752 assert fails(stdchecker
.xmltags
, "Click <a href=\"page.html\">", "Klik <a hverw=\"page.html\">")
753 assert passes(stdchecker
.xmltags
, "Click <a xml-lang=\"en\" href=\"page.html\">", "Klik <a xml-lang=\"af\" href=\"page.html\">")
754 assert fails(stdchecker
.xmltags
, "Click <a href=\"page.html\" target=\"koei\">", "Klik <a href=\"page.html\">")
755 assert fails(stdchecker
.xmltags
, "<b>Current Translation</b>", "<b>Traducción Actual:<b>")
756 assert passes(stdchecker
.xmltags
, "<Error>", "<Fout>")
757 assert fails(stdchecker
.xmltags
, "%d/%d translated\n(%d blank, %d fuzzy)", "<br>%d/%d μεταφρασμένα\n<br>(%d κενά, %d ασαφή)")
758 frchecker
= checks
.StandardChecker(checks
.CheckerConfig(targetlanguage
="fr"))
759 assert fails(frchecker
.xmltags
, "Click <a href=\"page.html\">", "Klik <a href=« page.html »>")
761 def test_ooxmltags():
762 """Tests the xml tags in OpenOffice.org translations for quality as done in gsicheck"""
763 ooochecker
= checks
.OpenOfficeChecker()
764 #some attributes can be changed or removed
765 assert fails(ooochecker
.xmltags
, "<img src=\"a.jpg\" width=\"400\">", "<img src=\"b.jpg\" width=\"500\">")
766 assert passes(ooochecker
.xmltags
, "<img src=\"a.jpg\" width=\"400\">", "<img src=\"a.jpg\" width=\"500\">")
767 assert passes(ooochecker
.xmltags
, "<img src=\"a.jpg\" width=\"400\">", "<img src=\"a.jpg\">")
768 assert passes(ooochecker
.xmltags
, "<img src=\"a.jpg\">", "<img src=\"a.jpg\" width=\"400\">")
769 assert passes(ooochecker
.xmltags
, "<alt xml-lang=\"ab\">text</alt>", "<alt>teks</alt>")
770 assert passes(ooochecker
.xmltags
, "<ahelp visibility=\"visible\">bla</ahelp>", "<ahelp>blu</ahelp>")
771 assert fails(ooochecker
.xmltags
, "<ahelp visibility=\"visible\">bla</ahelp>", "<ahelp visibility=\"invisible\">blu</ahelp>")
772 assert fails(ooochecker
.xmltags
, "<ahelp visibility=\"invisible\">bla</ahelp>", "<ahelp>blu</ahelp>")
773 #some attributes can be changed, but not removed
774 assert passes(ooochecker
.xmltags
, "<link name=\"John\">", "<link name=\"Jan\">")
775 assert fails(ooochecker
.xmltags
, "<link name=\"John\">", "<link naam=\"Jan\">")
777 def test_functions():
778 """tests to see that funtions() are not translated"""
779 stdchecker
= checks
.StandardChecker()
780 assert fails(stdchecker
.functions
, "blah rgb() blah", "blee brg() blee")
781 assert passes(stdchecker
.functions
, "blah rgb() blah", "blee rgb() blee")
782 assert fails(stdchecker
.functions
, "percentage in rgb()", "phesenthe kha brg()")
783 assert passes(stdchecker
.functions
, "percentage in rgb()", "phesenthe kha rgb()")
784 assert fails(stdchecker
.functions
, "rgb() in percentage", "brg() kha phesenthe")
785 assert passes(stdchecker
.functions
, "rgb() in percentage", "rgb() kha phesenthe")
786 assert fails(stdchecker
.functions
, "blah string.rgb() blah", "blee bleeb.rgb() blee")
787 assert passes(stdchecker
.functions
, "blah string.rgb() blah", "blee string.rgb() blee")
788 assert passes(stdchecker
.functions
, "or domain().", "domain() verwag.")
789 assert passes(stdchecker
.functions
, "Expected url(), url-prefix(), or domain().", "url(), url-prefix() of domain() verwag.")
792 """tests to see that email addresses are not translated"""
793 stdchecker
= checks
.StandardChecker()
794 assert fails(stdchecker
.emails
, "blah bob@example.net blah", "blee kobus@voorbeeld.net blee")
795 assert passes(stdchecker
.emails
, "blah bob@example.net blah", "blee bob@example.net blee")
798 """tests to see that URLs are not translated"""
799 stdchecker
= checks
.StandardChecker()
800 assert fails(stdchecker
.urls
, "blah http://translate.org.za blah", "blee http://vertaal.org.za blee")
801 assert passes(stdchecker
.urls
, "blah http://translate.org.za blah", "blee http://translate.org.za blee")
803 def test_simpleplurals():
804 """test that we can find English style plural(s)"""
805 stdchecker
= checks
.StandardChecker()
806 assert passes(stdchecker
.simpleplurals
, "computer(s)", "rekenaar(s)")
807 assert fails(stdchecker
.simpleplurals
, "plural(s)", "meervoud(e)")
808 assert fails(stdchecker
.simpleplurals
, "Ungroup Metafile(s)...", "Kuvhanganyululani Metafaela(dzi)...")
810 # Test a language that doesn't use plurals
811 stdchecker
= checks
.StandardChecker(checks
.CheckerConfig(targetlanguage
='vi'))
812 assert passes(stdchecker
.simpleplurals
, "computer(s)", u
"Máy tính")
813 assert fails(stdchecker
.simpleplurals
, "computer(s)", u
"Máy tính(s)")
816 """Test that we can find the wrong number of plural forms. Note that this
817 test uses a UnitChecker, not a translation checker."""
818 checker
= checks
.StandardUnitChecker()
821 unit
.source
= ["%d file", "%d files"]
822 unit
.target
= [u
"%d lêer", u
"%d lêers"]
823 assert checker
.nplurals(unit
)
825 checker
= checks
.StandardUnitChecker(checks
.CheckerConfig(targetlanguage
='af'))
826 unit
.source
= "%d files"
827 unit
.target
= "%d lêer"
828 assert checker
.nplurals(unit
)
830 unit
.source
= ["%d file", "%d files"]
831 unit
.target
= [u
"%d lêer", u
"%d lêers"]
832 assert checker
.nplurals(unit
)
834 unit
.source
= ["%d file", "%d files"]
835 unit
.target
= [u
"%d lêer", u
"%d lêers", u
"%d lêeeeers"]
836 assert not checker
.nplurals(unit
)
838 unit
.source
= ["%d file", "%d files"]
839 unit
.target
= [u
"%d lêer"]
840 assert not checker
.nplurals(unit
)
842 checker
= checks
.StandardUnitChecker(checks
.CheckerConfig(targetlanguage
='km'))
843 unit
.source
= "%d files"
844 unit
.target
= "%d ឯកសារ"
845 assert checker
.nplurals(unit
)
847 unit
.source
= ["%d file", "%d files"]
848 unit
.target
= [u
"%d ឯកសារ"]
849 assert checker
.nplurals(unit
)
851 unit
.source
= ["%d file", "%d files"]
852 unit
.target
= [u
"%d ឯកសារ", u
"%d lêers"]
853 assert not checker
.nplurals(unit
)
857 stdchecker
= checks
.StandardChecker()
858 assert passes(stdchecker
.credits
, "File", "iFayile")
859 assert passes(stdchecker
.credits
, "&File", "&Fayile")
860 assert passes(stdchecker
.credits
, "translator-credits", "Ekke, ekke!")
861 assert passes(stdchecker
.credits
, "Your names", "Ekke, ekke!")
862 assert passes(stdchecker
.credits
, "ROLES_OF_TRANSLATORS", "Ekke, ekke!")
863 kdechecker
= checks
.KdeChecker()
864 assert passes(kdechecker
.credits
, "File", "iFayile")
865 assert passes(kdechecker
.credits
, "&File", "&Fayile")
866 assert passes(kdechecker
.credits
, "translator-credits", "Ekke, ekke!")
867 assert fails(kdechecker
.credits
, "Your names", "Ekke, ekke!")
868 assert fails(kdechecker
.credits
, "ROLES_OF_TRANSLATORS", "Ekke, ekke!")
869 gnomechecker
= checks
.GnomeChecker()
870 assert passes(gnomechecker
.credits
, "File", "iFayile")
871 assert passes(gnomechecker
.credits
, "&File", "&Fayile")
872 assert fails(gnomechecker
.credits
, "translator-credits", "Ekke, ekke!")
873 assert passes(gnomechecker
.credits
, "Your names", "Ekke, ekke!")
874 assert passes(gnomechecker
.credits
, "ROLES_OF_TRANSLATORS", "Ekke, ekke!")