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.

66 lines
1.5 KiB

  1. #!/usr/bin/php
  2. <?php
  3. define('DOCUMENT_ROOT', dirname(__FILE__));
  4. require_once(DOCUMENT_ROOT.'/bootstrap.php');
  5. $bootstrap = new Bootstrap();
  6. $bootstrap->boot();
  7. $argsize = count($argv);
  8. if($argsize == 1) {
  9. echo
  10. "Welcome to Mud - Movim Unified Doer
  11. Here some requests you can do with me :
  12. - comploc compile the current locales to a simple PHP array to boost Movim execution
  13. ";
  14. } elseif($argsize == 2) {
  15. switch ($argv[1]) {
  16. case 'comploc':
  17. comploc();
  18. break;
  19. /*case 1:
  20. echo "i égal 1";
  21. break;
  22. case 2:
  23. echo "i égal 2";
  24. break;*/
  25. }
  26. }
  27. function comploc() {
  28. echo "Locales compiler\n";
  29. $folder = DOCUMENT_ROOT.'/cache/locales/';
  30. if(!file_exists($folder)) {
  31. $bool = mkdir($folder);
  32. if(!$bool) {
  33. echo "The locales cache folder can't be created";
  34. exit;
  35. }
  36. } else
  37. echo "Folder already exist, don't re-create it\n";
  38. $langs = load_lang_array();
  39. foreach($langs as $key => $value) {
  40. $langarr = parse_lang_file(DOCUMENT_ROOT . '/locales/' . $key . '.po');
  41. $out = '<?php global $translations;
  42. $translations = array(';
  43. foreach($langarr as $msgid => $msgstr)
  44. if($msgid != '')
  45. $out .= '"'.$msgid.'" => "'. $msgstr . '",'."\n";
  46. $out .= ');';
  47. $fp = fopen($folder.$key.'.php', 'w');
  48. fwrite($fp, $out);
  49. fclose($fp);
  50. }
  51. }
  52. echo "\n";