1
0

update-locales.php 893 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. if (!extension_loaded('intl')) {
  8. echo 'Intl extension is required to run this script.';
  9. exit(1);
  10. }
  11. require '../3rdparty/autoload.php';
  12. $locales = array_map(static function (string $localeCode) {
  13. return [
  14. 'code' => $localeCode,
  15. 'name' => Locale::getDisplayName($localeCode, 'en')
  16. ];
  17. }, ResourceBundle::getLocales(''));
  18. $locales = array_filter($locales, static function (array $locale) {
  19. return is_array(Punic\Data::explodeLocale($locale['code']));
  20. });
  21. $locales = array_values($locales);
  22. if (file_put_contents(__DIR__ . '/locales.json', json_encode($locales, JSON_PRETTY_PRINT)) === false) {
  23. echo 'Failed to update locales.json';
  24. exit(1);
  25. }
  26. echo 'Updated locales.json. Don\'t forget to commit the result.';
  27. exit(0);