def convertelement(self, theoo): """convert an oo element into a list of base units (.po or XLIFF)""" if self.sourcelanguage in theoo.languages: part1 = theoo.languages[self.sourcelanguage] else: logging.error("/".join(theoo.lines[0].getkey()) + "language not found: %s", self.sourcelanguage) return [] if self.blankmsgstr: # use a blank part2 part2 = oo.ooline() else: if self.targetlanguage in theoo.languages: part2 = theoo.languages[self.targetlanguage] else: # if the language doesn't exist, the translation is missing ... so make it blank part2 = oo.ooline() if "x-comment" in theoo.languages: translators_comment = theoo.languages["x-comment"] else: translators_comment = oo.ooline() key = oo.makekey(part1.getkey(), self.long_keys) unitlist = [] for subkey in ("text", "quickhelptext", "title"): unit = self.maketargetunit(part1, part2, translators_comment, key, subkey) if unit is not None: unitlist.append(unit) return unitlist
def convertelement(self, theoo): """convert an oo element into a list of base units (.po or XLIFF)""" if self.sourcelanguage in theoo.languages: part1 = theoo.languages[self.sourcelanguage] else: logging.error( "/".join(theoo.lines[0].getkey()) + "language not found: %s", self.sourcelanguage) return [] if self.blankmsgstr: # use a blank part2 part2 = oo.ooline() else: if self.targetlanguage in theoo.languages: part2 = theoo.languages[self.targetlanguage] else: # if the language doesn't exist, the translation is missing ... so make it blank part2 = oo.ooline() if "x-comment" in theoo.languages: translators_comment = theoo.languages["x-comment"] else: translators_comment = oo.ooline() key = oo.makekey(part1.getkey(), self.long_keys) unitlist = [] for subkey in ("text", "quickhelptext", "title"): unit = self.maketargetunit(part1, part2, translators_comment, key, subkey) if unit is not None: unitlist.append(unit) return unitlist
def test_makekey(): """checks the makekey function for consistency""" assert oo.makekey(('project', r'path\to\the\sourcefile.src', 'resourcetype', 'GROUP_ID', 'LOCAL_ID', 'platform'), False) == "sourcefile.src#GROUP_ID.LOCAL_ID.resourcetype" # Testwith long_key i.e. used in multifile options assert oo.makekey(('project', r'path\to\the\sourcefile.src', 'resourcetype', 'GROUP_ID', 'LOCAL_ID', 'platform'), True) == "project/path/to/the/sourcefile.src#GROUP_ID.LOCAL_ID.resourcetype" assert oo.makekey(('project', r'path\to\the\sourcefile.src', 'resourcetype', 'GROUP_ID', '', 'platform'), False) == "sourcefile.src#GROUP_ID.resourcetype" assert oo.makekey(('project', r'path\to\the\sourcefile.src', 'resourcetype', '', 'LOCAL_ID', 'platform'), False) == "sourcefile.src#LOCAL_ID.resourcetype" assert oo.makekey(('project', r'path\to\the\sourcefile.src', '', 'GROUP_ID', 'LOCAL_ID', 'platform'), False) == "sourcefile.src#GROUP_ID.LOCAL_ID" assert oo.makekey(('project', r'path\to\the\sourcefile.src', '', 'GROUP_ID', '', 'platform'), False) == "sourcefile.src#GROUP_ID"
def makeindex(self): """makes an index of the oo keys that are used in the source file""" self.index = {} for ookey, theoo in self.o.ookeys.items(): sourcekey = oo.makekey(ookey, self.long_keys) self.index[sourcekey] = theoo
def makeindex(self): """makes an index of the oo keys that are used in the source file""" self.index = {} for ookey, theoo in self.o.ookeys.iteritems(): sourcekey = oo.makekey(ookey, self.long_keys) self.index[sourcekey] = theoo
def test_makekey(): """checks the makekey function for consistency""" assert (oo.makekey( ( "project", r"path\to\the\sourcefile.src", "resourcetype", "GROUP_ID", "LOCAL_ID", "platform", ), False, ) == "sourcefile.src#GROUP_ID.LOCAL_ID.resourcetype") # Testwith long_key i.e. used in multifile options assert (oo.makekey( ( "project", r"path\to\the\sourcefile.src", "resourcetype", "GROUP_ID", "LOCAL_ID", "platform", ), True, ) == "project/path/to/the/sourcefile.src#GROUP_ID.LOCAL_ID.resourcetype") assert (oo.makekey( ( "project", r"path\to\the\sourcefile.src", "resourcetype", "GROUP_ID", "", "platform", ), False, ) == "sourcefile.src#GROUP_ID.resourcetype") assert (oo.makekey( ( "project", r"path\to\the\sourcefile.src", "resourcetype", "", "LOCAL_ID", "platform", ), False, ) == "sourcefile.src#LOCAL_ID.resourcetype") assert (oo.makekey( ( "project", r"path\to\the\sourcefile.src", "", "GROUP_ID", "LOCAL_ID", "platform", ), False, ) == "sourcefile.src#GROUP_ID.LOCAL_ID") assert (oo.makekey( ("project", r"path\to\the\sourcefile.src", "", "GROUP_ID", "", "platform"), False, ) == "sourcefile.src#GROUP_ID")