]> git.mxchange.org Git - friendica.git/blob - util/extract.php
FR update to the strings THX Perig
[friendica.git] / util / extract.php
1 <?php
2
3         $arr = array();
4
5         $files = array('index.php','boot.php');
6         $files = array_merge($files,glob('mod/*'),glob('include/*'),glob('addon/*/*'));
7
8
9         foreach($files as $file) {
10                 $str = file_get_contents($file);
11
12                 $pat = '| t\(([^\)]*)\)|';
13                 $patt = '| tt\(([^\)]*)\)|';
14
15                 preg_match_all($pat,$str,$matches);
16                 preg_match_all($patt, $str, $matchestt);
17                 
18
19                 if(count($matches)){
20                         foreach($matches[1] as $match) {
21                                 if(! in_array($match,$arr))
22                                         $arr[] = $match;
23                         }
24                 }
25                 if(count($matchestt)){
26                         foreach($matchestt[1] as $match) {
27                                 $matchtkns = preg_split("|[ \t\r\n]*,[ \t\r\n]*|",$match);
28                                 if (count($matchtkns)==3 && !in_array($matchtkns,$arr)){
29                                         $arr[] = $matchtkns;
30                                 }
31                         }
32                 }
33
34         }
35
36         $s = '<?php' . "\n";
37         $s .= '
38 function string_plural_select($n){
39         return ($n != 1);
40 }
41
42 ';
43
44         foreach($arr as $a) {
45                 if (is_array($a)){
46                         if(substr($a[1],0,1) == '$')
47                                 continue;
48                         $s .= '$a->strings[' . $a[0] . "] = array(\n";
49                         $s .= "\t0 => ". $a[0]. ",\n";
50                         $s .= "\t1 => ". $a[1]. ",\n";
51                         $s .= ");\n";
52                 } else {
53                         if(substr($a,0,1) == '$')
54                                 continue;                       
55                         $s .= '$a->strings[' . $a . '] = '. $a . ';' . "\n";
56                 }
57         }
58
59         $zones = timezone_identifiers_list();
60         foreach($zones as $zone)
61                 $s .= '$a->strings[\'' . $zone . '\'] = \'' . $zone . '\';' . "\n";
62         
63         echo $s;