Here's my prototype: feedback is appreciated!
(Part1): Model and DDL
<?php
class Translation extends AppModel {
var $name = 'Translation';
var $useTable = 'ax_translation';
function import($filename) {
// set the filename to read from
if (empty($filename)) $filename='default.pot';
$filename = ROOT . DS . 'app' . DS. 'locale' . DS . $filename;
$filename= '/usr/local/www/41max.com/www/dev/app/locale/
default.pot';
// open the file
$filehandle = fopen($filename, "r");
while (($row = fgets($filehandle)) !== FALSE) {
if (substr($row,0,7) == 'msgid "') {
// parse string in hochkomma:
$msgid = substr($row, 7 ,(strpos($row,'"',6)-8));
if (!empty($msgid)) {
$row = fgets($filehandle);
if (substr($row,0,8) == 'msgstr "') {
$msgstr = substr($row, 8 ,(strpos($row,'"',7)-9));
}
// check if exists
$trec = $this->find(array("Translation.msgid" =>
$msgid, "locale"=>"en"));
if (empty($trec)) {
$this->create();
$this->data['Translation']['msgid'] = $msgid;
$this->data['Translation']['msgstr'] = $msgstr;
$this->data['Translation']['locale'] = 'en';
$this->data['Translation']['status'] = 'n';
$this->save($this->data);
} else {
$this->setLastUsed($trec['Translation']['id']);
}
}
}
}
fclose($filehandle);
}
function setLastUsed($id) {
$ret = $this->query("update ax_translation ax set last_used =
current_timestamp where id = " . $id);
return $ret;
}
}
?>
/*
CREATE TABLE ax_translation (
id serial,
msgid varchar(255) not null ,
locale char(2) default 'en',
created timestamp with time zone,
last_used timestamp with time zone,
status char(1), -- (t:translated, n: new, needs translation, r:
to be reviewed, u: updated, needs translation
msgstr text
);
CREATE UNIQUE INDEX ax_translation_msgid ON ax_translation USING btree
(msgid, locale);
*/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---