Created
February 26, 2020 06:08
-
-
Save Q0/4b53ce48acae656c4e1d12e91e4046de to your computer and use it in GitHub Desktop.
Заменяет все строки в шаблоне CodeIgniter для поддержки PO файлов
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$path = realpath(__DIR__ . '/application/views/'); // | |
$fileList = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::SELF_FIRST); | |
foreach ($fileList as $item) { | |
if ($item->isFile() && stripos($item->getPathName(), 'php') !== false) { | |
$file_contents = file_get_contents($item->getPathName()); | |
$file_contents = preg_replace_callback('/<\?php echo \$this->lang->line\(\'(.*)\'\);\?>/m', function($matches) use (&$replacements) { | |
$pathLang = realpath(__DIR__ . '/application/language/russian/'); // | |
include $pathLang.'/app_lang.php'; | |
return "<?=__('".$lang[$matches[1]]."');?>"; | |
}, $file_contents); | |
file_put_contents($item->getPathName(),$file_contents); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment