Find out what the fallback language is for a given language choice.

        .. versionadded 1.5
968180
def get_fallback_languages(self, language_code=None, site_id=None):
        
        choices = self.get_active_choices(language_code, site_id=site_id)
        return choices[1:]
154793
def get_object(self, queryset=None):
        
        if queryset is None:
            queryset = self.get_queryset()

        slug = self.kwargs[self.slug_url_kwarg]
        choices = self.get_language_choices()

        obj = None
        using_fallback = False
        prev_choices = []
        for lang_choice in choices:
            try:
                # Get the single item from the filtered queryset
                # NOTE. Explicitly set language to the state the object was fetched in.
                filters = self.get_translated_filters(slug=slug)
                obj = queryset.translated(lang_choice, **filters).language(lang_choice).get()
            except ObjectDoesNotExist:
                # Translated object not found, next object is marked as fallback.
                using_fallback = True
                prev_choices.append(lang_choice)
            else:
                break

        if obj is None:
            tried_msg = ", tried languages: {0}".format(", ".join(choices))
            error_message = translation.ugettext("No %(verbose_name)s found matching the query") % {'verbose_name': queryset.model._meta.verbose_name}
            raise Http404(error_message + tried_msg)

        # Object found!
        if using_fallback:
            # It could happen that objects are resolved using their fallback language,
            # but the actual translation also exists. Either that means this URL should
            # raise a 404, or a redirect could be made as service to the users.
            # It's possible that the old URL was active before in the language domain/subpath
            # when there was no translation yet.
            for prev_choice in prev_choices:
                if obj.has_translation(prev_choice):
                    # Only dispatch() and render_to_response() can return a valid response,
                    # By breaking out here, this functionality can't be broken by users overriding render_to_response()
                    raise FallbackLanguageResolved(obj, prev_choice)

        return obj
1090354
public function showFallbackWarning()
    {
        $request = $this->requestStack->getCurrentRequest();

        if ($request->query->has('act')) {
            return;
        }

        $messages = \System::importStatic('Messages');
        \Message::addRaw($messages->languageFallback());

        if ($this->hasInvalidTopLevels()) {
            \Message::addRaw('<p class="tl_error">'.$GLOBALS['TL_LANG']['ERR']['topLevelRegular'].'</p>');
        }
    }
185046
private function getFallbackLocale($locale = null)
    {
        if ($locale && $this->isLocaleCountryBased($locale)) {
            if ($fallback = $this->getLanguageFromCountryBasedLocale($locale)) {
                return $fallback;
            }
        }

        $locales = $this->getLocales();

        foreach ($locales as $code) {
            if ($this->getTranslationByLocaleKey($code) !== null)
                return $code;
        }

        return app()->make('config')->get('revy.translatable.fallback_locale');
    }
631568
def __get_return_value(self, messageKey, value):
        
        # if value is not None, return it
        # otherwise, either use the Translations fallback if there is one,
        # or return the message key back
        if value:
            return value
        else:
            if self._fallback:
                return self._fallback.gettext(messageKey)
            else:
                return messageKey
1259574
def languages
      if default_language != nil
        # Use specified default language as primary language
        [default_language]
      else
        # Calculate the intersection of native development and used languages,
        # fallback to the latter only, if it is empty
        languages = native_dev_languages & used_languages
        if languages.empty?
          used_languages
        else
          languages
        end
      end
    end
879333
def get_cached_translated_field(instance, field_name, language_code=None, use_fallback=False):
    
    if language_code is None:
        language_code = instance.get_current_language()

    # In django-parler 1.1 the order of the arguments was fixed, It used to be language_code, field_name
    # This serves as detection against backwards incompatibility issues.
    if len(field_name) <= 5 and len(language_code) > 5:
        raise RuntimeError("Unexpected language code, did you swap field_name, language_code?")

    translated_model = instance._parler_meta.get_model_by_field(field_name)
    values = _get_cached_values(instance, translated_model, language_code, use_fallback)
    if not values:
        return None

    # Allow older cached versions where the field didn't exist yet.
    return values.get(field_name, None)
437705
protected function _getFallbackCatalogue()
    {
        if (!$this->_fallback_catalogue instanceof KTranslatorCatalogueInterface) {
            $this->_setFallbackCatalogue($this->getObject($this->_fallback_catalogue));
        }

        return $this->_fallback_catalogue;
    }
183511
def __get_language_data(self, bundleId, languageId, fallback=False):
        
        url = self.__get_base_bundle_url() + '/' + bundleId + '/' + languageId
        params = {'fallback': 'true'} if fallback else None
        response = self.__perform_rest_call(requestURL=url, params=params)

        if not response:
            return None

        languageData = response.get(self.__RESPONSE_RESOURCE_STRINGS_KEY)

        return languageData
467751
function switchBackFromEmbeddedLanguageIfNecessary(context) {
			var current = last(context.embeddedLanguageStack),
				lang;
			
			if (current && current.switchBack(context)) {
				context.language = languages[current.parentLanguage];
				lang = context.embeddedLanguageStack.pop();
				
				//restore old items
				context.items = clone(lang.oldItems);
				lang.oldItems = {};
			}
		}
407806
def get_fallback_languages():
    """"""
    lang = translation.get_language()
    fallback_list = settings.FALLBACK_LANGUAGES.get(lang, None)
    if fallback_list:
        return fallback_list

    return settings.FALLBACK_LANGUAGES.get(lang[:2], [])
946184
function IMFClass(opts) {
  if (!(this instanceof IMFClass)) {
    return new IMFClass(opts);
  }

  opts = opts || {};
  this.defaultNamespace = opts.defaultNamespace || '';
  this.defaultSeparator = opts.defaultSeparator === undefined ? '.' : opts.defaultSeparator;
  this.basePath = opts.basePath || 'locales/';
  this.fallbackLanguages = opts.fallbackLanguages;

  this.localeFileResolver = opts.localeFileResolver || function (lang) {
    return this.basePath + lang + '.json';
  };

  this.locales = opts.locales || [];
  this.langs = opts.langs;
  this.fallbackLocales = opts.fallbackLocales || [];

  const loadFallbacks = cb => {
    this.loadLocales(this.fallbackLanguages, function (...fallbackLocales) {
      this.fallbackLocales.push(...fallbackLocales);

      if (cb) {
        return cb(fallbackLocales);
      }
    }, true);
  };

  if (opts.languages || opts.callback) {
    this.loadLocales(opts.languages, () => {
      const locales = Array.from(arguments);

      const runCallback = fallbackLocales => {
        if (opts.callback) {
          opts.callback.apply(this, [this.getFormatter(opts.namespace), this.getFormatter.bind(this), locales, fallbackLocales]);
        }
      };

      if (opts.hasOwnProperty('fallbackLanguages')) {
        loadFallbacks(runCallback);
      } else {
        runCallback();
      }
    });
  } else if (opts.hasOwnProperty('fallbackLanguages')) {
    loadFallbacks();
  }
}
839925
function (translationId, interpolateParams, Interpolator, defaultTranslationText, sanitizeStrategy) {
      // Start with the fallbackLanguage with index 0
      return resolveForFallbackLanguage((startFallbackIteration > 0 ? startFallbackIteration : fallbackIndex), translationId, interpolateParams, Interpolator, defaultTranslationText, sanitizeStrategy);
    }
284835
public Locale getFallbackLocale() {

		Locale locale = null;
		if (this.fallbackToSystemLocale) {
			locale = Locale.getDefault();
		} else {
			locale = new Locale("", "");
		}

		return locale;
	}
1013905
def install_language(language):
    """"""
    translator = get_translator(default_domain, default_directory,
        languages=[get_lang(language)], fallback=True)
    do_unicode = True
    translator.install(do_unicode)
857262
public function find()
    {
        if (null === static::$locale) {
            /**
             * 1. resolve locale
             * 2. find resolved locale using provider
             * 3. if not found resolved locale => fetch default locale using provider
             */
            if (! ($resolved = $this->resolver->resolve()) ||
                ! ($locale = $this->provider->find($resolved))
            ) {
                $resolved = config('app.fallback_locale');
                if (! $locale = $this->provider->find($resolved)) {
                    $locale = $this->getDefault();
                }
            }

            static::$locale = $locale;
        }

        return static::$locale;
    }
619626
def get_render_language(contentitem):
    
    plugin = contentitem.plugin

    if plugin.render_ignore_item_language \
    or (plugin.cache_output and plugin.cache_output_per_language):
        # Render the template in the current language.
        # The cache also stores the output under the current language code.
        #
        # It would make sense to apply this for fallback content too,
        # but that would be ambiguous however because the parent_object could also be a fallback,
        # and that case can't be detected here. Hence, better be explicit when desiring multi-lingual content.
        return get_language()  # Avoid switching the content,
    else:
        # Render the template in the ContentItem language.
        # This makes sure that {% trans %} tag output matches the language of the model field data.
        return contentitem.language_code