def pofiles_to_unique_translations_dicts(pofiles):
    """Extracts unique translations from a set of PO files.

    Given multiple pofiles, extracts translations (those messages with non
    empty msgstrs) into two dictionaries, a dictionary for translations
    with contexts and other without them.

    Args:
        pofiles (list): List of :py:class:`polib.POFile` objects.

    Returns:
        tuple: dictionaries with translations.
    """
    translations, translations_with_msgctxt = ({}, {})
    for pofile in pofiles:
        for entry in pofile:
            if entry.msgctxt:
                if entry.msgctxt not in translations_with_msgctxt:
                    translations_with_msgctxt[entry.msgctxt] = {}
                translations_with_msgctxt[
                    entry.msgctxt
                ][entry.msgid] = entry.msgstr
            else:
                translations[entry.msgid] = entry.msgstr
    return (translations, translations_with_msgctxt)