protected function formatString($string, $args = array(), $catalogue = null)
{
if (empty($catalogue)) {
if (empty($this->Catalogue)) {
$catalogue = 'messages';
} else {
$catalogue = $this->Catalogue;
}
}
$this->loadCatalogue($catalogue);
if (empty($args)) {
$args = array();
}
foreach ($this->messages[$catalogue] as $variant) {
// foreach of the translation units
foreach ($variant as $source => $result) {
// we found it, so return the target translation
if ($source == $string) {
//check if it contains only strings.
if (is_string($result)) {
$target = $result;
} else {
$target = $result[0];
}
//found, but untranslated
if (empty($target)) {
return $this->postscript[0] . strtr($string, $args) . $this->postscript[1];
} else {
return strtr($target, $args);
}
}
}
}
// well we did not find the translation string.
$this->source->append($string);
return $this->postscript[0] . strtr($string, $args) . $this->postscript[1];
}