i18nstrings_cache($context, $langcode, $string = NULL, $translation = NULL)
contributions/i18n/i18nstrings/i18nstrings.module, line 563
Retrieves and stores translations in page (static variable) cache.
<?php
function i18nstrings_cache($context, $langcode, $string = NULL, $translation = NULL) {
static $strings;
$context = i18nstrings_context($context);
if (!$context->oid && $string) {
// This is a type indexed by string
$context->oid = $string;
}
// At this point context must have at least textgroup and type
if ($translation) {
if ($context->property) {
$strings[$langcode][$context->textgroup][$context->type][$context->oid][$context->property] = $translation;
} elseif ($context->oid) {
$strings[$langcode][$context->textgroup][$context->type][$context->oid] = $translation;
} else {
$strings[$langcode][$context->textgroup][$context->type] = $translation;
}
} else {
// Search up the tree for the object or a default
$search = &$strings[$langcode];
$default = NULL;
$list = array('textgroup', 'type', 'oid', 'property');
while (($field = array_shift($list)) && !empty($context->$field)) {
if (isset($search[$context->$field])) {
$search = &$search[$context->$field];
if (isset($search['#default'])) {
$default = $search['#default'];
}
} else {
// We dont have cached this tree so we return the default
return $default;
}
}
// Returns the part of the array we got to
return $search;
}
}
?>