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.
8 use PhpMyAdmin\Advisor;
14 * Processes single advisor message and stores data in global array.
16 function add_message($file, $rules, $idx, $type) {
17 global $messages, $locations;
19 if ($type == 'justification') {
20 $msgs = Advisor::splitJustification($rules['rules'][$idx]);
23 $msg = $rules['rules'][$idx][$type];
25 $line = $file . ':' . $rules['lines'][$idx][$type];
26 // Avoid duplicate mesages
27 $pos = array_search($msg, $messages);
30 $locations[] = array($line);
32 $locations[$pos][] = $line;
37 * Prints message at given location as Gettext string for translation.
39 function print_message($idx) {
40 global $messages, $locations;
42 echo '#: ' . implode(' ', $locations[$idx]);
44 if (strstr($messages[$idx], '%') !== false) {
48 echo 'msgid "' . addcslashes(Advisor::escapePercent($messages[$idx]), '"\\') . '"';
54 define('PHPMYADMIN', 1);
55 require_once 'libraries/vendor_config.php';
56 require_once AUTOLOAD_FILE;
59 $ruleFiles[Advisor::GENERIC_RULES_FILE] = Advisor::parseRulesFile(Advisor::GENERIC_RULES_FILE);
60 $ruleFiles[Advisor::BEFORE_MYSQL80003_RULES_FILE] = Advisor::parseRulesFile(Advisor::BEFORE_MYSQL80003_RULES_FILE);
62 foreach ($ruleFiles as $file => $rules) {
63 foreach ($rules['rules'] as $idx => $rule) {
64 add_message($file, $rules, $idx, 'name');
65 add_message($file, $rules, $idx, 'issue');
66 add_message($file, $rules, $idx, 'recommendation');
67 add_message($file, $rules, $idx, 'justification');
71 foreach($messages as $idx => $rule) {