phpmyadmin/scripts/match-twig-cache
William Desportes e9e7696962
Improve update-po script and add match-twig-cache script
- Make update-po script return the same order on all workstations
- Make it work on MacOSX
- Remove .phtml extension
- Exclude node_modules folder
- match-twig-cache is made to replace templates by the real file and --reverse way
- this change is made so the order is kept between po files updates

I want to stop unreadable diffs between po files updates. 

Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-03-12 13:10:27 +01:00

29 lines
786 B
PHP

<?php
/* vim: set expandtab sw=4 ts=4 sts=4 ft=php: */
declare(strict_types=1);
if (! defined('ROOT_PATH')) {
define('ROOT_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR);
}
$tmpDir = ROOT_PATH . 'twig-templates';
/* Read replacements file */
$replacements = json_decode(file_get_contents($tmpDir . '/replace.json'), true);
/* Read files list */
$filesList = file_get_contents($tmpDir . '/filesList');
$options = getopt('', ['reverse::']);
foreach ($replacements as $templateName => $data) {
if (isset($options['reverse'])) {
$filesList = str_replace($data[0], $templateName, $filesList);
} else {
$filesList = str_replace($templateName, $data[0], $filesList);
}
}
/* Write back files list */
file_put_contents($tmpDir . '/filesList', $filesList);