<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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"):   # Support ISO 639-1 Language Codes (e.g. "en")
            return lang + "$core"
        else:
            raise ValueError("Unsupported language '{}'. Supported languages: {}".format(
                lang, ", ".join(cls.SUPPORTED_LANGUAGES)))