Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.3 KiB

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