def add_string_pairs_from_attributed_ui_element(results, ui_element, comment_prefix):
    """ Adds string pairs from a UI element with attributed text

    Args:
        results (list): The list to add the results to.
        attributed_element (element): The element from the xib that contains, to extract the fragments from.
        comment_prefix (str): The prefix of the comment to use for extracted string
                              (will be appended "Part X" suffices)

    Returns:
        bool: Whether or not an attributed string was found.
    """
    attributed_strings = ui_element.getElementsByTagName('attributedString')
    if attributed_strings.length == 0:
        return False

    attributed_element = attributed_strings[0]
    fragment_index = 1
    for fragment in attributed_element.getElementsByTagName('fragment'):
        # The fragment text is either as an attribute <fragment content="TEXT">
        # or a child in the format <string key='content'>TEXT</string>
        try:
            label_entry_key = fragment.attributes['content'].value
        except KeyError:
            label_entry_key = fragment.getElementsByTagName('string')[0].firstChild.nodeValue

        comment = "%s Part %d" % (comment_prefix, fragment_index)
        results.append((label_entry_key, comment))
        fragment_index += 1

    return fragment_index > 1
def add_string_pairs_from_attributed_ui_element ( results , ui_element , comment_prefix ) : attributed_strings = ui_element . getElementsByTagName ( 'attributedString' ) if attributed_strings . length == 0 : return False attributed_element = attributed_strings [ 0 ] fragment_index = 1 for fragment in attributed_element . getElementsByTagName ( 'fragment' ) : try : label_entry_key = fragment . attributes [ 'content' ] . value except KeyError : label_entry_key = fragment . getElementsByTagName ( 'string' ) [ 0 ] . firstChild . nodeValue comment = "%s Part %d" % ( comment_prefix , fragment_index ) results . append ( ( label_entry_key , comment ) ) fragment_index += 1 return fragment_index > 1
Adds string pairs from a UI element with attributed text

    Args:
        results (list): The list to add the results to.
        attributed_element (element): The element from the xib that contains, to extract the fragments from.
        comment_prefix (str): The prefix of the comment to use for extracted string
                              (will be appended "Part X" suffices)

    Returns:
        bool: Whether or not an attributed string was found.