def group_pluralized_forms(dict):
    """Return a dictionary where the pluralized forms from dict are
    grouped. Elements of the form
    (msg, i) -> tr1
    ...
    (msg, j) -> trn
    are grouped into:
    msg -> [tr1, ..., trn]
    """
    result = {}
    keys = dict.keys()
    keys.sort()
    for k in keys:
        translation = dict[k]
        if type(k) is tuple:
            # A pluralized form k = (msg, n)
            k = k[0]
            if k not in result:
                result[k] = []
            result[k].append(translation)
        else:
            result[k] = translation
    return result