def getOrthographyReferenced(crappyReferenceString, row, orthographies):
    """Return the id of the orthography model referenced in ``crappyReferenceString``.
    ``crappyReferenceString`` is something like "Orthography 1" or "Object Language Orthography 3"
    and ``row`` is a row in the applicationsettings table.  ``orthographies`` is a dict from
    orthography names to orthography ids.

    """
    orthographyName = row['objectLanguageOrthography%sName' % crappyReferenceString.split()[-1]]
    return orthographies.get(orthographyName, None)