def test_to_unicode(self): unit = tiki.TikiUnit("one") unit.target = 'two' assert str(unit) == '"one" => "two",\n' unit2 = tiki.TikiUnit("one") unit2.target = 'two' unit2.addlocation('untranslated') assert str(unit2) == '// "one" => "two",\n'
def test_to_unicode(self): unit = tiki.TikiUnit("one") unit.settarget('two') assert six.text_type(unit) == '"one" => "two",\n' unit2 = tiki.TikiUnit("one") unit2.settarget('two') unit2.addlocation('untranslated') assert six.text_type(unit2) == '// "one" => "two",\n'
def test_to_unicode(): unit = tiki.TikiUnit("one") unit.target = "two" assert str(unit) == '"one" => "two",\n' unit2 = tiki.TikiUnit("one") unit2.target = "two" unit2.addlocation("untranslated") assert str(unit2) == '// "one" => "two",\n'
def convertstore(self, thepofile): """Converts a given (parsed) po file to a tiki file. :param thepofile: a pofile pre-loaded with input data """ thetargetfile = tiki.TikiStore() for unit in thepofile.units: if not (unit.isblank() or unit.isheader()): newunit = tiki.TikiUnit(unit.source) newunit.target = unit.target locations = unit.getlocations() if locations: newunit.addlocations(locations) # If a word is "untranslated" but the target isn't empty and isn't the same as the source # it's been translated and we switch it. This is an assumption but should remain true as long # as these scripts are used. if newunit.getlocations() == ["untranslated"] and unit.source != unit.target and unit.target != "": newunit.location = [] newunit.addlocation("translated") thetargetfile.addunit(newunit) return thetargetfile
def test_locations(self): unit = tiki.TikiUnit("one") unit.addlocation('blah') assert unit.getlocations() == [] unit.addlocation('unused') assert unit.getlocations() == ['unused']
def test_locations(self): unit = tiki.TikiUnit("one") unit.addlocation("blah") assert unit.getlocations() == [] unit.addlocation("unused") assert unit.getlocations() == ["unused"]