You are here

function i18nstrings_get_string in Internationalization 5.3

Same name and namespace in other branches
  1. 5 experimental/i18nstrings.module \i18nstrings_get_string()
  2. 5.2 experimental/i18nstrings.module \i18nstrings_get_string()
  3. 6 i18nstrings/i18nstrings.module \i18nstrings_get_string()

Get string for a language.

Return value

object The translation object if found with lid and translation properties

2 calls to i18nstrings_get_string()
i18nstrings_admin_form in i18nstrings/i18nstrings.module
Form callback: i18nstrings_admin_form
i18nstrings_tt in i18nstrings/i18nstrings.module
Translate configurable string, and store for l10n client

File

i18nstrings/i18nstrings.module, line 127
Internationalization (i18n) package - translattable strings

Code

function i18nstrings_get_string($strid, $language = FALSE, $default = NULL, $refresh = FALSE) {
  static $strings = array();
  if ($refresh) {
    $language ? $strings[$language] = array() : ($strings = array());
  }
  if (!isset($strings[$language][$strid])) {
    $translation = db_fetch_object(db_query("SELECT s.lid, t.translation FROM {i18n_locale} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.locale = '%s' WHERE s.strid = '%s'", $language, $strid));
    if ($translation) {
      $strings[$language][$strid] = $translation->translation ? $translation : FALSE;
    }
    else {

      // Looks like this string is not in the collection, add it
      $source = i18nstrings_save_string($strid, $default);
      $strings[$language][$strid] = $source;
    }
  }
  return $strings[$language][$strid];
}