You are here

function i18n_string in Internationalization 7

Translate or update user defined string. Entry point for i18n_string API if enabled.

This function is from i18n_string sub module and is subject to be moved back.

Parameters

$name: Textgroup and context glued with ':'.

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

$options: An associative array of additional options, with the following keys:

  • 'langcode' (defaults to the current language) The language code to translate to a language other than what is used to display the page.
  • 'filter' Filtering callback to apply to the translated string only
  • 'format' Input format to apply to the translated string only
  • 'callback' Callback to apply to the result (both to translated or untranslated string
  • 'update' (defaults to FALSE) Whether to update source table
  • 'translate' (defaults to TRUE) Whether to return a translation

Return value

$string Translated string, $string if not found

11 calls to i18n_string()
i18n_block_block_view_alter in i18n_block/i18n_block.module
Implements hook_block_view_alter().
i18n_forum_preprocess_forums in i18n_forum/i18n_forum.module
Translate forum page.
i18n_forum_preprocess_forum_list in i18n_forum/i18n_forum.module
Translate forums list.
i18n_menu_localize_elements in i18n_menu/i18n_menu.module
Localize menu renderable array
i18n_menu_menu_overview_title in i18n_menu/i18n_menu.module
Title callback for the menu overview page and links.

... See full list

21 string references to 'i18n_string'
i18nStringTestCase::setUp in i18n_string/i18n_string.test
Sets up a Drupal site for running functional and integration tests.
i18nSyncTestCase::setUp in i18n_sync/i18n_sync.test
Sets up a Drupal site for running functional and integration tests.
i18n_field_page_translate in i18n_field/i18n_field.pages.inc
Field translation page
i18n_field_update_7000 in i18n_field/i18n_field.install
Implements hook_i18n_drupal6_update().
i18n_node_update_7000 in i18n_node/i18n_node.install
Implements hook_i18n_update_drupal6().

... See full list

File

./i18n.module, line 362
Internationalization (i18n) module.

Code

function i18n_string($name, $string, $options = array()) {
  $options += array(
    'translate' => TRUE,
    'update' => FALSE,
  );
  if ($options['update']) {
    $result = function_exists('i18n_string_update') ? i18n_string_update($name, $string, $options) : FALSE;
  }
  if ($options['translate']) {
    $result = function_exists('i18n_string_translate') ? i18n_string_translate($name, $string, $options) : $string;
  }
  return $result;
}