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)))
Ensure a language identifier has the correct duckling format and is supported.