diff --git a/core/modules/locale/lib/Drupal/locale/LocaleLookup.php b/core/modules/locale/lib/Drupal/locale/LocaleLookup.php index 2003e4e..cd40afe 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleLookup.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleLookup.php @@ -102,6 +102,27 @@ protected function resolveCacheMiss($offset) { ))->addLocation('path', request_uri())->save(); $value = TRUE; } + + // If there is no translation available for current language + // then use language fallback to try other translations + if ($value === TRUE) { + $fallbacks = language_fallback_get_candidates($this->langcode); + if (!empty($fallbacks)) { + foreach($fallbacks as $langcode) { + $translation = $this->stringStorage->findTranslation(array( + 'language' => $langcode, + 'source' => $offset, + 'context' => $this->context, + )); + + if ($translation && !empty($translation->translation)) { + $value = $translation->translation; + break; + } + } + } + } + $this->storage[$offset] = $value; // Disabling the usage of string caching allows a module to watch for // the exact list of strings used on a page. From a performance