function update($text, $target, $comments, $catalogue = 'messages')
{
$variants = $this->getVariants($catalogue);
if ($variants) {
list($variant, $MOFile, $POFile) = $variants;
} else {
return false;
}
if (is_writable($MOFile) == false) {
throw new TIOException("Unable to update file {$MOFile}, file must be writable.");
}
if (is_writable($POFile) == false) {
throw new TIOException("Unable to update file {$POFile}, file must be writable.");
}
$po = TGettext::factory('PO', $POFile);
$po->load();
$result = $po->toArray();
foreach ($result['strings'] as $string => $value) {
if ($string == $text) {
$result['strings'][$string] = $target;
$result['meta']['PO-Revision-Date'] = @date('Y-m-d H:i:s');
$po->fromArray($result);
$mo = $po->toMO();
if ($po->save() && $mo->save($MOFile)) {
if (!empty($this->cache)) {
$this->cache->clean($variant, $this->culture);
}
return true;
} else {
return false;
}
}
}
return false;
}