2 declare(strict_types=1);
4 if (! defined('ROOT_PATH')) {
5 define('ROOT_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR);
8 $tmpDir = dirname(__FILE__) . '/../twig-templates';
9 $potName = 'po/phpmyadmin.pot';
10 $replacements = json_decode(file_get_contents($tmpDir . '/replace.json'), true);
13 $pot = file_get_contents($potName);
15 /* Do the replacements */
16 $pot = preg_replace_callback(
17 '@(twig-templates[0-9a-f/]*.php):([0-9]*)@',
20 $filename = $matches[1];
21 $line = intval($matches[2]);
22 $replace = $replacements[$filename];
23 foreach ($replace[1] as $cacheline => $result) {
24 if ($line >= $cacheline) {
25 return $replace[0] . ':' . $result;
28 return $replace[0] . ':0';
33 /* Write fixed file */
34 $handle = fopen($potName, 'w');
35 fwrite($handle, $pot);