You are here

public function views_plugin_localization_core::save_string in Views (for Drupal 7) 7.3

Same name and namespace in other branches
  1. 6.3 plugins/views_plugin_localization_core.inc \views_plugin_localization_core::save_string()

Save a string for translation.

Parameters

string $string: The string to be translated.

array $keys: An array of keys to identify the string. Generally constructed from view name, display_id, and a property, e.g., 'header'.

string $format: The input format of the string. This is optional.

Overrides views_plugin_localization::save_string

File

plugins/views_plugin_localization_core.inc, line 41
Definition of views_plugin_localization_core.

Class

views_plugin_localization_core
Localization plugin to pass translatable strings through t().

Code

public function save_string($string, $keys = array(), $format = '') {
  global $language;

  // If the current language is 'en', we need to reset the language
  // in order to trigger an update.
  // @todo add test for number of languages.
  if ($language->language == 'en') {
    $changed = TRUE;
    $languages = language_list();
    $cached_language = $language;
    unset($languages['en']);
    if (!empty($languages)) {
      $language = current($languages);
    }
  }
  t($string);
  if (isset($cached_language)) {
    $language = $cached_language;
  }
  return TRUE;
}