@classmethod
def convert_to_duckling_language_id(cls, lang):
    """Ensure a language identifier has the correct duckling format and is supported."""
    if lang is not None and cls.is_supported(lang):
        return lang
    elif lang is not None and cls.is_supported(lang + '$core'):
        return lang + '$core'
    else:
        raise ValueError("Unsupported language '{}'. Supported languages: {}"
            .format(lang, ', '.join(cls.SUPPORTED_LANGUAGES)))
