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.
 
 
 
 
 
 

71 lines
1.2 KiB

  1. <?php
  2. if(! class_exists('App')) {
  3. class TmpA {
  4. public $strings = Array();
  5. }
  6. $a = new TmpA();
  7. }
  8. if ($argc!=2) {
  9. print "Usage: ".$argv[0]." <strings.php>\n\n";
  10. return;
  11. }
  12. $phpfile = $argv[1];
  13. $pofile = dirname($phpfile)."/messages.po";
  14. if (!file_exists($phpfile)){
  15. print "Unable to find '$phpfile'\n";
  16. return;
  17. }
  18. include_once($phpfile);
  19. print "Out to '$pofile'\n";
  20. $out = "";
  21. $infile = file($pofile);
  22. $k="";
  23. $ink = False;
  24. foreach ($infile as $l) {
  25. if ($k!="" && substr($l,0,7)=="msgstr "){
  26. $ink = False;
  27. $v = '""';
  28. //echo "DBG: k:'$k'\n";
  29. if (isset($a->strings[$k])) {
  30. $v= '"'.$a->strings[$k].'"';
  31. //echo "DBG\n";
  32. //var_dump($k, $v, $a->strings[$k], $v);
  33. //echo "/DBG\n";
  34. }
  35. //echo "DBG: v:'$v'\n";
  36. $l = "msgstr ".$v."\n";
  37. }
  38. if (substr($l,0,6)=="msgid_" || substr($l,0,7)=="msgstr[" )$ink = False;;
  39. if ($ink) {
  40. $k .= trim($l,"\"\r\n");
  41. $k = str_replace('\"','"',$k);
  42. }
  43. if (substr($l,0,6)=="msgid "){
  44. $arr=False;
  45. $k = str_replace("msgid ","",$l);
  46. if ($k != '""' ) {
  47. $k = trim($k,"\"\r\n");
  48. $k = str_replace('\"','"',$k);
  49. } else {
  50. $k = "";
  51. }
  52. $ink = True;
  53. }
  54. $out .= $l;
  55. }
  56. //echo $out;
  57. file_put_contents($pofile, $out);
  58. ?>