def METHOD_NAME(
    self,
    contextname,
    source,
    translation,
    comment=None,
    transtype=None,
    createifmissing=False,
):
    """adds the given translation (will create the nodes required if asked). Returns success"""
    contextnode = self.getcontextnode(contextname)
    if contextnode is None:
        if not createifmissing:
            return False
        # construct a context node with the given name
        contextnode = self.document.createElement("context")
        namenode = self.document.createElement("name")
        nametext = self.document.createTextNode(contextname)
        namenode.appendChild(nametext)
        contextnode.appendChild(namenode)
        self.document.documentElement.appendChild(contextnode)
    if not createifmissing:
        return False
    messagenode = self.document.createElement("message")
    sourcenode = self.document.createElement("source")
    sourcetext = self.document.createTextNode(source)
    sourcenode.appendChild(sourcetext)
    messagenode.appendChild(sourcenode)
    if comment:
        commentnode = self.document.createElement("comment")
        commenttext = self.document.createTextNode(comment)
        commentnode.appendChild(commenttext)
        messagenode.appendChild(commentnode)
    translationnode = self.document.createElement("translation")
    translationtext = self.document.createTextNode(translation)
    translationnode.appendChild(translationtext)
    if transtype:
        translationnode.setAttribute("type", transtype)
    messagenode.appendChild(translationnode)
    contextnode.appendChild(messagenode)
    return True