From 4f35efa0bad4ae6489b63f3eebafe6542d654094 Mon Sep 17 00:00:00 2001 From: RedMatrix Date: Wed, 31 Dec 2014 10:43:19 +1100 Subject: Revert "Language names via intl library." --- library/intl/scripts/language/generate.php | 129 ----------------------------- 1 file changed, 129 deletions(-) delete mode 100644 library/intl/scripts/language/generate.php (limited to 'library/intl/scripts/language') diff --git a/library/intl/scripts/language/generate.php b/library/intl/scripts/language/generate.php deleted file mode 100644 index e11c8df49..000000000 --- a/library/intl/scripts/language/generate.php +++ /dev/null @@ -1,129 +0,0 @@ - $languageName) { - if (strpos($languageCode, '-alt-') === FALSE) { - $languages['en'][$languageCode] = array( - 'code' => $languageCode, - 'name' => $languageName, - ); - } -} - -// Gather available locales. -$locales = array(); -if ($handle = opendir('../json-full/main')) { - while (false !== ($entry = readdir($handle))) { - if (substr($entry, 0, 1) != '.') { - $entryParts = explode('-', $entry); - if (!in_array($entry, $ignoredLocales) && !in_array($entryParts[0], $ignoredLocales)) { - $locales[] = $entry; - } - } - } - closedir($handle); -} - -// Remove all languages that aren't an available locale at the same time. -// This reduces the language list from about 515 to about 185 languages. -foreach ($languages['en'] as $languageCode => $languageData) { - if (!in_array($languageCode, $locales)) { - unset($languages['en'][$languageCode]); - } -} - -// Load the localizations. -foreach ($locales as $locale) { - $data = json_decode(file_get_contents('../json-full/main/' . $locale . '/languages.json'), true); - $data = $data['main'][$locale]['localeDisplayNames']['languages']; - foreach ($data as $languageCode => $languageName) { - if (isset($languages['en'][$languageCode])) { - // This language name is untranslated, use to the english version. - if ($languageCode == $languageName) { - $languageName = $languages['en'][$languageCode]['name']; - } - - $languages[$locale][$languageCode] = array( - 'code' => $languageCode, - 'name' => $languageName, - ); - } - } -} - -// Identify localizations that are the same as the ones for the parent locale. -// For example, "fr-FR" if "fr" has the same data. -$duplicates = array(); -foreach ($languages as $locale => $localizedLanguages) { - if (strpos($locale, '-') !== FALSE) { - $localeParts = explode('-', $locale); - array_pop($localeParts); - $parentLocale = implode('-', $localeParts); - $diff = array_udiff($localizedLanguages, $languages[$parentLocale], function ($first, $second) { - return ($first['name'] == $second['name']) ? 0 : 1; - }); - - if (empty($diff)) { - // The duplicates are not removed right away because they might - // still be needed for other duplicate checks (for example, - // when there are locales like bs-Latn-BA, bs-Latn, bs). - $duplicates[] = $locale; - } - } -} -// Remove the duplicates. -foreach ($duplicates as $locale) { - unset($languages[$locale]); -} - -// Write out the localizations. -foreach ($languages as $locale => $localizedLanguages) { - $collator = collator_create($locale); - uasort($localizedLanguages, function($a, $b) use ($collator) { - return collator_compare($collator, $a['name'], $b['name']); - }); - - $json = json_encode($localizedLanguages, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); - file_put_contents($locale . '.json', $json); -} -- cgit v1.2.3