Welcome to mirror list, hosted at ThFree Co, Russian Federation.

fix-po-twig « scripts - github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 606ba20010eed80e002055fc57d59d2d2d425222 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/* vim: set expandtab sw=4 ts=4 sts=4 ft=php: */
declare(strict_types=1);

$tmpDir = dirname(__FILE__) . '/../twig-templates';
$potName = 'po/phpmyadmin.pot';
$replacements = json_decode(file_get_contents($tmpDir . '/replace.json'), true);

/* Read pot file */
$pot = file_get_contents($potName);

/* Do the replacements */
$pot = preg_replace_callback(
    '@(twig-templates[0-9a-f/]*.php):([0-9]*)@',
    function ($matches) {
        global $replacements;
        $filename = $matches[1];
        $line = intval($matches[2]);
        $replace = $replacements[$filename];
        foreach ($replace[1] as $cacheline => $result) {
            if ($line >= $cacheline) {
                return $replace[0] . ':' . $result;
            }
        }
        return $replace[0] . ':0';
    },
    $pot
);

/* Write fixed file */
$handle = fopen($potName, 'w');
fwrite($handle, $pot);
fclose($handle);