Package translate :: Package filters :: Module test_checks

[hide private]
[frames] | no frames]

# Source Code for Module translate.filters.test_checks

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