Trees | Indices | Help |
|
---|
|
1 #!/usr/bin/env python 2 3 from translate.storage import tmx 4 from translate.storage import test_base 5 from translate.misc import wStringIO 6 911 tmxsource = '''<?xml version="1.0" encoding="utf-8"?> 12 <!DOCTYPE tmx 13 SYSTEM 'tmx14.dtd'> 14 <tmx version="1.4"> 15 <header adminlang="en" creationtool="Translate Toolkit - po2tmx" creationtoolversion="1.0beta" datatype="PlainText" o-tmf="UTF-8" segtype="sentence" srclang="en"/> 16 <body> 17 <tu> 18 <tuv xml:lang="en"> 19 <seg>Test String</seg> 20 </tuv> 21 <tuv xml:lang="af"> 22 <seg>Toets String</seg> 23 </tuv> 24 </tu> 25 </body> 26 </tmx>''' 273133 StoreClass = tmx.tmxfile 347836 """helper that parses tmx source without requiring files""" 37 dummyfile = wStringIO.StringIO(tmxsource) 38 print tmxsource 39 tmxfile = tmx.tmxfile(dummyfile) 40 return tmxfile4143 tmxfile = tmx.tmxfile() 44 assert tmxfile.translate("Anything") is None 45 tmxfile.addtranslation("A string of characters", "en", "'n String karakters", "af") 46 assert tmxfile.translate("A string of characters") == "'n String karakters"4749 """tests that addtranslation() stores strings correctly""" 50 tmxfile = tmx.tmxfile() 51 tmxfile.addtranslation("A string of characters", "en", "'n String karakters", "af") 52 newfile = self.tmxparse(str(tmxfile)) 53 print str(tmxfile) 54 assert newfile.translate("A string of characters") == "'n String karakters"5557 """test addtranslation() with newlines""" 58 tmxfile = tmx.tmxfile() 59 tmxfile.addtranslation("First line\nSecond line", "en", "Eerste lyn\nTweede lyn", "af") 60 newfile = self.tmxparse(str(tmxfile)) 61 print str(tmxfile) 62 assert newfile.translate("First line\nSecond line") == "Eerste lyn\nTweede lyn"6365 """Test that the xml entities '&' and '<' are escaped correctly""" 66 tmxfile = tmx.tmxfile() 67 tmxfile.addtranslation("Mail & News", "en", "Nuus & pos", "af") 68 tmxfile.addtranslation("Five < ten", "en", "Vyf < tien", "af") 69 xmltext = str(tmxfile) 70 print "The generated xml:" 71 print xmltext 72 assert tmxfile.translate('Mail & News') == 'Nuus & pos' 73 assert xmltext.index('Mail & News') 74 assert xmltext.find('Mail & News') == -1 75 assert tmxfile.translate('Five < ten') == 'Vyf < tien' 76 assert xmltext.index('Five < ten') 77 assert xmltext.find('Five < ten') == -1
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Mar 26 12:49:35 2008 | http://epydoc.sourceforge.net |