function save($catalogue = 'messages')
{
$messages = $this->untranslated;
if (count($messages) <= 0) {
return false;
}
$variants = $this->getVariants($catalogue);
if ($variants) {
list($variant, $MOFile, $POFile) = $variants;
} else {
list($variant, $MOFile, $POFile) = $this->createMessageTemplate($catalogue);
}
if (is_writable($MOFile) == false) {
throw new TIOException("Unable to save to file {$MOFile}, file must be writable.");
}
if (is_writable($POFile) == false) {
throw new TIOException("Unable to save to file {$POFile}, file must be writable.");
}
//set the strings as untranslated.
$strings = array();
foreach ($messages as $message) {
$strings[$message] = '';
}
//load the PO
$po = TGettext::factory('PO', $POFile);
$po->load();
$result = $po->toArray();
$existing = count($result['strings']);
//add to strings to the existing message list
$result['strings'] = array_merge($result['strings'], $strings);
$new = count($result['strings']);
if ($new > $existing) {
//change the date 2004-12-25 12:26
$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;
}