from pathlib import Path


def replace_parent(path, parent, new_parent):
    """
    Forge a new path a parent path into a new parent path.

    Useful to get corresponding path from translation file to original file, or from original file to translation file.

    :param pathlib.Path path: the path to translate
    :param pathlib.Path parent: one of the path parents, to remove
    :param str new_parent: new path to inject in place of parent
    :return: forged path
    :rtype: pathlib.Path
    """
    parent_str = parent.as_posix()
    child_str = path.as_posix()
    child_suffix = child_str[len(parent_str):]  # includes first char '/' if path != parent
    return Path("{}{}".format(new_parent.as_posix(), child_suffix))