2 /* vim: set expandtab sw=4 ts=4 sts=4 ft=php: */
3 declare(strict_types=1);
5 if (! defined('ROOT_PATH')) {
6 define('ROOT_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR);
9 $tmpDir = dirname(__FILE__) . '/../twig-templates';
10 $potName = 'po/phpmyadmin.pot';
11 $replacements = json_decode(file_get_contents($tmpDir . '/replace.json'), true);
14 $pot = file_get_contents($potName);
16 /* Do the replacements */
17 $pot = preg_replace_callback(
18 '@(twig-templates[0-9a-f/]*.php):([0-9]*)@',
21 $filename = $matches[1];
22 $line = intval($matches[2]);
23 $replace = $replacements[$filename];
24 foreach ($replace[1] as $cacheline => $result) {
25 if ($line >= $cacheline) {
26 return $replace[0] . ':' . $result;
29 return $replace[0] . ':0';
34 /* Write fixed file */
35 $handle = fopen($potName, 'w');
36 fwrite($handle, $pot);