st
- Versions
- 5 – 7
st($string, $args = array())
Functional equivalent of t(), used when some systems are not available.
Used during the install process, when database, theme, and localization system is possibly not yet available.
See also
t()
Code
includes/install.inc, line 939
<?php
function st($string, $args = array()) {
static $locale_strings = NULL;
global $install_state;
if (!isset($locale_strings)) {
$locale_strings = array();
if (isset($install_state['parameters']['profile']) && isset($install_state['parameters']['locale'])) {
$filename = 'profiles/' . $install_state['parameters']['profile'] . '/translations/' . $install_state['parameters']['locale'] . '.po';
if (file_exists(DRUPAL_ROOT . '/' . $filename)) {
require_once DRUPAL_ROOT . '/includes/locale.inc';
$file = (object) array('uri' => $filename);
_locale_import_read_po('mem-store', $file);
$locale_strings = _locale_import_one_string('mem-report');
}
}
}
require_once DRUPAL_ROOT . '/includes/theme.inc';
// Transform arguments before inserting them
foreach ($args as $key => $value) {
switch ($key[0]) {
// Escaped only
case '@':
$args[$key] = check_plain($value);
break;
// Escaped and placeholder
case '%':
default:
$args[$key] = '<em>' . check_plain($value) . '</em>';
break;
// Pass-through
case '!':
}
}
return strtr((!empty($locale_strings[$string]) ? $locale_strings[$string] : $string), $args);
}
?>Login or register to post comments 