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 </tu> 22 </body> 23 </tmx>''' 242830 StoreClass = tmx.tmxfile 317533 """helper that parses tmx source without requiring files""" 34 dummyfile = wStringIO.StringIO(tmxsource) 35 print tmxsource 36 tmxfile = tmx.tmxfile(dummyfile) 37 return tmxfile3840 tmxfile = tmx.tmxfile() 41 assert tmxfile.translate("Anything") is None 42 tmxfile.addtranslation("A string of characters", "en", "'n String karakters", "af") 43 assert tmxfile.translate("A string of characters") == "'n String karakters"4446 """tests that addtranslation() stores strings correctly""" 47 tmxfile = tmx.tmxfile() 48 tmxfile.addtranslation("A string of characters", "en", "'n String karakters", "af") 49 newfile = self.tmxparse(str(tmxfile)) 50 print str(tmxfile) 51 assert newfile.translate("A string of characters") == "'n String karakters"5254 """test addtranslation() with newlines""" 55 tmxfile = tmx.tmxfile() 56 tmxfile.addtranslation("First line\nSecond line", "en", "Eerste lyn\nTweede lyn", "af") 57 newfile = self.tmxparse(str(tmxfile)) 58 print str(tmxfile) 59 assert newfile.translate("First line\nSecond line") == "Eerste lyn\nTweede lyn"6062 """Test that the xml entities '&' and '<' are escaped correctly""" 63 tmxfile = tmx.tmxfile() 64 tmxfile.addtranslation("Mail & News", "en", "Nuus & pos", "af") 65 tmxfile.addtranslation("Five < ten", "en", "Vyf < tien", "af") 66 xmltext = str(tmxfile) 67 print "The generated xml:" 68 print xmltext 69 assert tmxfile.translate('Mail & News') == 'Nuus & pos' 70 assert xmltext.index('Mail & News') 71 assert xmltext.find('Mail & News') == -1 72 assert tmxfile.translate('Five < ten') == 'Vyf < tien' 73 assert xmltext.index('Five < ten') 74 assert xmltext.find('Five < ten') == -1
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Sep 23 13:51:07 2008 | http://epydoc.sourceforge.net |