You are here

public function i18n_string_object::get_translation in Internationalization 7

Get translation to language from string object

1 call to i18n_string_object::get_translation()
i18n_string_object::format_translation in i18n_string/i18n_string.inc
Format the resulting translation or the default string applying callbacks

File

i18n_string/i18n_string.inc, line 168
API for internationalization strings

Class

i18n_string_object
String object that contains source and translations.

Code

public function get_translation($langcode) {
  if (!isset($this->translations[$langcode])) {
    $translation = $this
      ->textgroup()
      ->load_translation($this, $langcode);
    if ($translation && isset($translation->translation)) {
      $this
        ->set_translation($translation, $langcode);
    }
    else {

      // No source, no translation
      $this->translations[$langcode] = FALSE;
    }
  }

  // Which doesn't mean we've got a translation, only that we've got the result cached
  return $this->translations[$langcode];
}