def translate(source, vocab, populate=None, keys=None, solver=None):
    """Translate *source* Semantic Pointer to vocabulary *vocab*.

    The translation of a Semantic Pointer uses some form of projection to
    convert the source Semantic Pointer to a Semantic Pointer of another
    vocabulary. By default the outer products of terms in the source and
    target vocabulary are used, but if *solver* is given, it is used to find
    a least squares solution for this projection.

    Parameters
    ----------
    source : object
        Source of Semantic Pointer.
    vocab : Vocabulary
        Target vocabulary.
    populate : bool, optional
        Whether the target vocabulary should be populated with missing keys.
        This is done by default, but with a warning. Set this explicitly to
        *True* or *False* to silence the warning or raise an error.
    keys : list, optional
        All keys to translate. If *None*, all keys in the source vocabulary
        will be translated.
    solver : nengo.Solver, optional
        If given, the solver will be used to solve the least squares problem to
        provide a better projection for the translation.
    """
    if hasattr(source, 'translate'):
        return source.translate(vocab, populate, keys, solver)
    else:
        raise TypeError("bad operand type for 'translate'")
