You are here

function i18nstrings_tt in Internationalization 5.3

Translate configurable string, and store for l10n client

Parameters

$strid: Textgroup and location glued with ':' I.e. profile:

$default: String in default language. Default language may or may not be English

$langcode: Optional language code if different from current request language

$update: Whether to update/create the string

1 call to i18nstrings_tt()
tt in ./i18n.module
Translate configurable string, and store for l10n client.
1 string reference to 'i18nstrings_tt'
tt in ./i18n.module
Translate configurable string, and store for l10n client.

File

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

Code

function i18nstrings_tt($strid, $default, $language = NULL, $update = FALSE) {
  global $locale, $l10n_client_strings;

  //dsm("i18nstrings translating $strid $default");
  $language = $language ? $language : $locale;
  $string = NULL;
  if ($update) {
    i18nstrings_save_string($strid, $default);
  }
  if ($language == i18n_default_language()) {

    // We just translate from default language, not to default language
    return $default;
  }
  else {

    // We get the full source object to add it to l10n list, if not existing it will be created, so we get an lid
    $source = i18nstrings_get_string($strid, $language, $default);
    if (!empty($source->translation)) {
      $l10n_client_strings[$default] = $source;
      return $source->translation;
    }
    else {
      $l10n_client_strings[$default] = !empty($source) ? $source : TRUE;
      return $default;
    }
  }
}