friendica_2021-01/util/extract.php

63 lines
1.3 KiB
PHP
Raw Normal View History

2010-09-30 03:11:23 +02:00
<?php
$arr = [];
2010-09-30 03:11:23 +02:00
$files = ['index.php','boot.php'];
$files = array_merge($files,glob('mod/*'),glob('include/*'),glob('addon/*/*'));
2010-09-30 03:11:23 +02:00
foreach($files as $file) {
2010-09-30 03:11:23 +02:00
$str = file_get_contents($file);
$pat = '| t\(([^\)]*)\)|';
$patt = '| tt\(([^\)]*)\)|';
2010-09-30 03:11:23 +02:00
preg_match_all($pat,$str,$matches);
preg_match_all($patt, $str, $matchestt);
if(count($matches)){
foreach($matches[1] as $match) {
if(! in_array($match,$arr))
$arr[] = $match;
}
}
if(count($matchestt)){
foreach($matchestt[1] as $match) {
$matchtkns = preg_split("|[ \t\r\n]*,[ \t\r\n]*|",$match);
if (count($matchtkns)==3 && !in_array($matchtkns,$arr)){
$arr[] = $matchtkns;
}
}
2010-09-30 03:11:23 +02:00
}
}
$s = '<?php' . "\n";
$s .= '
function string_plural_select($n){
return ($n != 1);
}
2010-09-30 03:11:23 +02:00
';
foreach($arr as $a) {
if (is_array($a)){
if(substr($a[1],0,1) == '$')
continue;
$s .= '$a->strings[' . $a[0] . "] = array(\n";
$s .= "\t0 => ". $a[0]. ",\n";
$s .= "\t1 => ". $a[1]. ",\n";
$s .= ");\n";
} else {
if(substr($a,0,1) == '$')
continue;
$s .= '$a->strings[' . $a . '] = '. $a . ';' . "\n";
}
2010-09-30 03:11:23 +02:00
}
$zones = timezone_identifiers_list();
foreach($zones as $zone)
2010-09-30 03:11:23 +02:00
$s .= '$a->strings[\'' . $zone . '\'] = \'' . $zone . '\';' . "\n";
2010-09-30 03:11:23 +02:00
echo $s;