You are here

function i18nstrings_add_l10n_client in Internationalization 6

Add string to l10n strings if enabled and allowed for this string

Parameters

$langcode: Language code to translate to

$string: Original string to be translated (usually in default language)

$translation: Translated string if found

$context: Context object that must contain 'textgroup' property

$source: Source string object that must contain 'format' property FALSE for not checking the source format

2 calls to i18nstrings_add_l10n_client()
i18nstrings_text in i18nstrings/i18nstrings.module
Get filtered translation.
i18nstrings_translate_string in i18nstrings/i18nstrings.module
Get translation for user defined string.

File

i18nstrings/i18nstrings.module, line 319
Internationalization (i18n) package - translatable strings.

Code

function i18nstrings_add_l10n_client($langcode, $string, $translation, $context, $source = NULL) {
  global $language;

  // If current language add to l10n client list for later on page translation.
  // If langcode translation was disabled we are not supossed to reach here.
  if ($language->language == $langcode && function_exists('l10_client_add_string_to_page')) {
    $translation = $translation ? $translation : TRUE;
    if ($source === FALSE) {

      // This means it is a plain string, we don't need to check the format
      l10_client_add_string_to_page($string, $translation, $context->textgroup);
    }
    else {

      // Additional checking for input format, if its a dangerous one we ignore the string
      $source = $source ? $source : i18nstrings_get_source($context, $string);
      if (!empty($source) && (i18nstrings_allowed_format($source->format) || filter_access($source->format))) {
        l10_client_add_string_to_page($string, $translation, $context->textgroup);
      }
    }
  }
}