Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 23e04aeef2
Fetching contributors…

Cannot retrieve contributors at this time

69 lines (60 sloc) 1.777 kB
<?php
/* vim: set expandtab sw=4 ts=4 sts=4 ft=php: */
/**
* Script to parse advisor rules and output them as PHP code which can be used
* by gettext for generating po(t) files.
*/
function format_string($str) {
return addcslashes(Advisor::escapePercent($str), '"\\');
}
$messages = array();
$locations = array();
function add_message($rules, $idx, $type) {
global $messages, $locations;
// Get message text
if ($type == 'justification') {
$msgs = Advisor::splitJustification($rules['rules'][$idx]);
$msg = $msgs[0];
} else {
$msg = $rules['rules'][$idx][$type];
}
$line = 'libraries/advisory_rules.txt:' . $rules['lines'][$idx][$type];
// Avoid duplicate mesages
$pos = array_search($msg, $messages);
if ($pos === false) {
$messages[] = $msg;
$locations[] = array($line);
} else {
$locations[$pos][] = $line;
}
}
function print_message($idx) {
global $messages, $locations;
echo "\n";
echo '#: ' . implode(' ', $locations[$idx]);
echo "\n";
if (strstr($messages[$idx], '%') !== false) {
echo '#, php-format';
echo "\n";
}
echo 'msgid "' . addcslashes(Advisor::escapePercent($messages[$idx]), '"\\') . '"';
echo "\n";
echo 'msgstr ""';
echo "\n";
}
define('PHPMYADMIN', 1);
if (!file_exists('./libraries/Advisor.class.php')) {
chdir('..');
}
include './libraries/Advisor.class.php';
$rules = Advisor::parseRulesFile();
foreach($rules['rules'] as $idx => $rule) {
add_message($rules, $idx, 'name');
add_message($rules, $idx, 'issue');
add_message($rules, $idx, 'recommendation');
add_message($rules, $idx, 'justification');
}
foreach($messages as $idx => $rule) {
print_message($idx);
}
?>
Jump to Line
Something went wrong with that request. Please try again.