Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. $directories = [
  7. __DIR__ . '/../core/l10n',
  8. ];
  9. $isDebug = in_array('--debug', $argv, true) || in_array('-d', $argv, true);
  10. $apps = new \DirectoryIterator(__DIR__ . '/../apps');
  11. foreach ($apps as $app) {
  12. if (!file_exists($app->getPathname() . '/l10n')) {
  13. continue;
  14. }
  15. $directories[] = $app->getPathname() . '/l10n';
  16. }
  17. $errors = [];
  18. $valid = 0;
  19. foreach ($directories as $dir) {
  20. if (!file_exists($dir)) {
  21. continue;
  22. }
  23. $directory = new \DirectoryIterator($dir);
  24. foreach ($directory as $file) {
  25. if ($file->getExtension() !== 'json') {
  26. continue;
  27. }
  28. $content = file_get_contents($file->getPathname());
  29. $json = json_decode($content, true);
  30. $translations = json_encode($json['translations']);
  31. if (strpos($translations, '|') !== false) {
  32. $errors[] = $file->getPathname() . "\n" . ' ' . 'Contains a | in the translations.' . "\n";
  33. }
  34. if (json_last_error() !== JSON_ERROR_NONE) {
  35. $errors[] = $file->getPathname() . "\n" . ' ' . json_last_error_msg() . "\n";
  36. } else {
  37. $valid++;
  38. }
  39. if ($isDebug && $file->getFilename() === 'en_GB.json') {
  40. $sourceStrings = json_encode(array_keys($json['translations']));
  41. if (strpos($sourceStrings, '\u2019') !== false) {
  42. $errors[] = $file->getPathname() . "\n"
  43. . ' ' . 'Contains a unicode single quote "’" in the english source string, please replace with normal single quotes.' . "\n"
  44. . ' ' . 'Please note that this only updates after a sync to transifex.' . "\n";
  45. }
  46. }
  47. }
  48. }
  49. if (count($errors) > 0) {
  50. echo sprintf('ERROR: There were %d errors:', count($errors)) . "\n\n";
  51. echo implode("\n", $errors);
  52. exit(1);
  53. }
  54. echo 'OK: ' . $valid . ' files parse' . "\n";
  55. exit(0);