l10nParseAppInfo.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 Morris Jobke <hey@morrisjobke.de>
  4. *
  5. * @license GNU AGPL version 3 or any later version
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License as
  9. * published by the Free Software Foundation, either version 3 of the
  10. * License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. /**
  22. * This little script parses the info.xml and extracts the app name as well
  23. * as the navigation entry name from the XML and writes it into a file named
  24. * specialAppInfoFakeDummyForL10nScript.php that is created and deleted during
  25. * l10n string extraction
  26. */
  27. $fileName = getcwd() . '/appinfo/info.xml';
  28. $strings = [];
  29. if (!file_exists($fileName)) {
  30. exit();
  31. }
  32. $xml = simplexml_load_file($fileName);
  33. if ($xml->name) {
  34. $strings[] = $xml->name->__toString();
  35. }
  36. if ($xml->navigations) {
  37. foreach ($xml->navigations as $navigation) {
  38. $name = $navigation->navigation->name->__toString();
  39. if (!in_array($name, $strings)) {
  40. $strings[] = $name;
  41. }
  42. }
  43. }
  44. print_r($strings);
  45. $content = '<?php' . PHP_EOL;
  46. foreach ($strings as $string) {
  47. $content .= '$l->t("' . $string . '");' . PHP_EOL;
  48. }
  49. file_put_contents('specialAppInfoFakeDummyForL10nScript.php', $content);