def translate(text, conversion_dict, before=lambda _: _):
    """ Translate words from a text using a conversion dictionary

    @brief text The text to be translated
    @brief conversion_dict The conversion dictionary
    @brief before A function to transform the input
    """
    # if empty:
    if not text: return text
    # preliminary transformation:
    before = before or str.lower
    t = before(text)
    for key, value in conversion_dict.items():
        t = t.replace(key, value)
    return t