def get_translation(cls, language_code, create_if_necessary=False,
                    fallback=False, field=None):
    """
    Get a translation instance for the given `language_id_or_code`.

    If the translation does not exist:

    1. if `create_if_necessary` is True, this function will create one
    2. otherwise, if `fallback` is True, this function will search the
       list of languages looking for the first existing translation
    3. if all of the above fails to find a translation, raise the
    TranslationDoesNotExist exception
    """
    # fill the cache if necessary
    cls.fill_translation_cache()

    if language_code is None:
        language_code = getattr(cls, '_default_language', None)
    if language_code is None:
        language_code = get_default_language()

    force = False
    if GLL.is_active:
        language_code = GLL.language_code
        force = True

    if language_code in cls._translation_cache:
        transobj = cls._translation_cache.get(language_code, None)
        if field is None:
            return transobj    
        value = getattr(transobj, field)
        if value or force or (not fallback):
            return value

    if create_if_necessary:
        new_translation = cls._meta.translation_model(master=cls,
                                                      language_code=language_code)
        cls._translation_cache[language_code] = new_translation
        return new_translation
    # only fall backif we're not in 'force' mode (GLL)
    elif (not force) and fallback:
        for fb_lang_code in get_fallbacks(language_code):
            transobj = cls._translation_cache.get(fb_lang_code, None)
            if transobj:
                if field is None:
                    return transobj
                else:
                    value = getattr(transobj, field)
                    if value:
                        return value
    raise TranslationDoesNotExist(language_code)
dataset/ETHPy150Open hzlf/openbroadcast/website/multilingual/translation.py/get_translation/original