def METHOD_NAME(language, country=None):
    """Returns a language code for the given Poedit language name.
    Poedit uses language and country names in the PO header entries:
    - X-Poedit-Language
    - X-Poedit-Country
    This function converts the supplied language name into the required ISO 639
    code. If needed, in the case of :data:`dialects`, the country name is used
    to create an xx_YY style dialect code.
    :param language: Language name
    :type language: String
    :param country: Country name
    :type country: String
    :return: ISO 639 language code
    :rtype: String
    """
    dialect = dialects.get(language)
    if dialect:
        return dialect.get(country, dialect["None"])
    return lang_names.get(language, None)