| 1 | #!/usr/bin/php |
|---|
| 2 | <? |
|---|
| 3 | include('../includes/includes.inc.php'); |
|---|
| 4 | include('../includes/config/dntp.inc.php'); |
|---|
| 5 | |
|---|
| 6 | $lang = $argv[1]; |
|---|
| 7 | $messages = array(); |
|---|
| 8 | |
|---|
| 9 | function addslashes2($str) |
|---|
| 10 | { |
|---|
| 11 | return str_replace('"', '\"', $str); |
|---|
| 12 | } |
|---|
| 13 | |
|---|
| 14 | $db=&DB::connect($dsn); |
|---|
| 15 | if (DB::isError($db)) |
|---|
| 16 | error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' | Connexion SQL impossible : '.$db->getMessage()); |
|---|
| 17 | $db->setFetchMode(DB_FETCHMODE_ASSOC); |
|---|
| 18 | |
|---|
| 19 | $msgid_r = $db->query('SELECT id, msgid, msgid_plural, multiline, first_see FROM dntp_msgid WHERE status=? ORDER BY first_see', array('ok')); |
|---|
| 20 | |
|---|
| 21 | if(DB::isError($msg_r)) |
|---|
| 22 | error_log($msg_r->getUserInfo()); |
|---|
| 23 | else |
|---|
| 24 | while($message = $msgid_r->fetchRow()) |
|---|
| 25 | { |
|---|
| 26 | $msgstr = $db->getAssoc('SELECT `key`, msgstr, multiline FROM dntp_msgstr WHERE lang=? AND id=? AND last=? ORDER BY `key`', false, array($lang, $message['id'], 'y')); |
|---|
| 27 | $message['msgstr'] = $msgstr; |
|---|
| 28 | if($message['first_see'] != $first_see) |
|---|
| 29 | { |
|---|
| 30 | $first_see = $message['first_see']; |
|---|
| 31 | $messages[$message['id']] = $message; |
|---|
| 32 | } |
|---|
| 33 | else |
|---|
| 34 | { |
|---|
| 35 | $first_see = $message['first_see']; |
|---|
| 36 | unset($message['first_see']); |
|---|
| 37 | $messages[$message['id']] = $message; |
|---|
| 38 | } |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | $db->disconnect(); |
|---|
| 42 | |
|---|
| 43 | foreach($messages as $msg) |
|---|
| 44 | { |
|---|
| 45 | if($msg['first_see']) |
|---|
| 46 | print "\n\n# ".$msg['first_see']."\n"; |
|---|
| 47 | if($msg['msgstr']) |
|---|
| 48 | { |
|---|
| 49 | print '# id: '.$msg['id']."\n"; |
|---|
| 50 | if($msg['multiline'] == 'n') |
|---|
| 51 | print 'msgid "'.addslashes2($msg['msgid']).'"'."\n"; |
|---|
| 52 | elseif($msg['multiline'] == 'y') |
|---|
| 53 | { |
|---|
| 54 | print 'msgid ""'."\n"; |
|---|
| 55 | $msgid_ex = explode("\n", $msg['msgid']); |
|---|
| 56 | foreach($msgid_ex as $msgid_line) |
|---|
| 57 | if(strlen($msgid_line)>0) |
|---|
| 58 | print '"'.addslashes2($msgid_line).'"'."\n"; |
|---|
| 59 | |
|---|
| 60 | } |
|---|
| 61 | if($msg['msgid_plural']) |
|---|
| 62 | print 'msgid_plural "'.addslashes2($msg['msgid_plural']).'"'."\n"; |
|---|
| 63 | |
|---|
| 64 | if($msg['msgid_plural']) |
|---|
| 65 | { |
|---|
| 66 | foreach($msg['msgstr'] as $key=>$msgstr) |
|---|
| 67 | print 'msgstr['.$key.'] "'.addslashes2($msgstr['msgstr']).'"'."\n"; |
|---|
| 68 | } |
|---|
| 69 | else |
|---|
| 70 | if($msg['msgstr'][0]['multiline'] == 'y') |
|---|
| 71 | { |
|---|
| 72 | print 'msgstr ""'."\n"; |
|---|
| 73 | $msgstr_ex = explode("\n", $msg['msgstr'][0]['msgstr']); |
|---|
| 74 | foreach($msgstr_ex as $msgstr_line) |
|---|
| 75 | if(strlen($msgstr_line)>0) |
|---|
| 76 | print '"'.addslashes2($msgstr_line).'"'."\n"; |
|---|
| 77 | } |
|---|
| 78 | else |
|---|
| 79 | print 'msgstr "'.addslashes2($msg['msgstr'][0]['msgstr']).'"'."\n"; |
|---|
| 80 | print "\n"; |
|---|
| 81 | } |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | print "# lang: $lang\n"; |
|---|
| 85 | |
|---|
| 86 | ?> |
|---|