Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Update JSON lang files
#! /usr/bin/env php
<?php
$json = file_get_contents($argv[1]) or die('Failed to open input file');
$arr = json_decode($json, true);
$keys = array_keys($arr);
exec("/usr/bin/find -E system -regex '.*\.(html|php)$' -exec grep -E '__\(.+\)' {} \;", $out);
foreach ($out as $o)
{
preg_match_all('/__\([\'"](.+?)[\'"]\)/', $o, $matches);
foreach ($matches[1] as $m) {
if (!in_array($m, $keys)) {
$arr[$m] = $m;
}
}
}
echo json_encode($arr);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment