You are here

function i18n_string_context in Internationalization 7

Convert string name into textgroup and string context

Parameters

$name: Array or string concatenated with ':' that contains textgroup and string context

$replace: Parameter to replace the placeholder ('*') if we are dealing with multiple strings Or parameter to append to context if there's no placeholder

Return value

array The first element will be the text group name The second one will be an array with string name elements, without textgroup

10 calls to i18n_string_context()
i18nStringTestCase::stringSaveTranslation in i18n_string/i18n_string.test
Translate one string into the db
i18n_string_build in i18n_string/i18n_string.module
Create string class from string name
i18n_string_multiple in i18n_string/i18n_string.module
Translate / update multiple strings
i18n_string_remove in i18n_string/i18n_string.module
Remove source and translations for user defined string.
i18n_string_translate in i18n_string/i18n_string.module
Get translation for user defined string.

... See full list

File

i18n_string/i18n_string.module, line 415
Internationalization (i18n) package - translatable strings.

Code

function i18n_string_context($name, $replace = NULL) {
  $parts = is_array($name) ? $name : explode(':', $name);
  if ($replace) {
    $key = array_search('*', $parts);
    if ($key !== FALSE) {
      $parts[$key] = $replace;
    }
    elseif (count($parts) < 4) {
      array_push($parts, $replace);
    }
  }
  $textgroup = array_shift($parts);
  $context = $parts;
  return array(
    $textgroup,
    $context,
  );
}