You are here

public function LocaleContextHierarchy::offsetGet in Language Hierarchy 7

File

includes/LocaleContextHierarchy.class.inc, line 22
Definition of LocaleContextHierarchy.

Class

LocaleContextHierarchy
Class LocaleContextHierarchy

Code

public function offsetGet($offset) {
  if (function_exists('locale')) {
    $locale_t =& drupal_static('locale');
    $translation = locale($offset, $this->context, $this->langcode);

    // Check whether string returned was a translation or the untranslated original.
    // Have to check locale()'s static variable, because just comparing the strings
    // might be misleading. (Stupid example: (en) village == (fr) village.)
    if (isset($this->candidates) && $locale_t[$this->langcode][$this->context][$offset] === TRUE) {
      foreach ($this->candidates as $candidate) {
        $translation = locale($offset, $this->context, $candidate);
        if ($locale_t[$candidate][$this->context][$offset] !== TRUE) {
          break;
        }
      }
    }
    return $translation;
  }
  return $offset;
}