2 /* vim: set expandtab sw=4 ts=4 sts=4 ft=php: */
4 * Script to parse advisor rules and output them as Gettext POT formatted
5 * strings for translation.
12 * Processes single advisor message and stores data in global array.
14 function add_message($rules, $idx, $type) {
15 global $messages, $locations;
17 if ($type == 'justification') {
18 $msgs = Advisor::splitJustification($rules['rules'][$idx]);
21 $msg = $rules['rules'][$idx][$type];
23 $line = 'libraries/advisory_rules.txt:' . $rules['lines'][$idx][$type];
24 // Avoid duplicate mesages
25 $pos = array_search($msg, $messages);
28 $locations[] = array($line);
30 $locations[$pos][] = $line;
35 * Prints message at given location as Gettext string for translation.
37 function print_message($idx) {
38 global $messages, $locations;
40 echo '#: ' . implode(' ', $locations[$idx]);
42 if (strstr($messages[$idx], '%') !== false) {
46 echo 'msgid "' . addcslashes(Advisor::escapePercent($messages[$idx]), '"\\') . '"';
52 define('PHPMYADMIN', 1);
53 if (!file_exists('./libraries/Advisor.class.php')) {
56 include './libraries/String.class.php';
58 $GLOBALS['PMA_String'] = new PMA_String();
60 include './libraries/Advisor.class.php';
62 $rules = Advisor::parseRulesFile();
64 foreach($rules['rules'] as $idx => $rule) {
65 add_message($rules, $idx, 'name');
66 add_message($rules, $idx, 'issue');
67 add_message($rules, $idx, 'recommendation');
68 add_message($rules, $idx, 'justification');
71 foreach($messages as $idx => $rule) {