* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Intl\Data\Util; /** * Scans a directory with data files for locales. * * The name of each file with the extension ".txt" is considered, if it "looks" * like a locale: * * - the name must start with two letters; * - the two letters may optionally be followed by an underscore and any * sequence of other symbols. * * For example, "de" and "de_DE" are considered to be locales. "root" and "meta" * are not. * * @author Bernhard Schussek * * @internal */ class LocaleScanner { /** * Returns all locales found in the given directory. * * @param string $sourceDir The directory with ICU files * * @return array An array of locales. The result also contains locales that * are in fact just aliases for other locales. Use * {@link scanAliases()} to determine which of the locales * are aliases */ public function scanLocales($sourceDir) { $locales = glob($sourceDir.'/*.txt'); // Remove file extension and sort array_walk($locales, function (&$locale) { $locale = basename($locale, '.txt'); }); // Remove non-locales $locales = array_filter($locales, function ($locale) { return preg_match('/^[a-z]{2}(_.+)?$/', $locale); }); sort($locales); return $locales; } /** * Returns all locale aliases found in the given directory. * * @param string $sourceDir The directory with ICU files * * @return array An array with the locale aliases as keys and the aliased * locales as values */ public function scanAliases($sourceDir) { $locales = $this->scanLocales($sourceDir); $aliases = array(); // Delete locales that are no aliases foreach ($locales as $locale) { $content = file_get_contents($sourceDir.'/'.$locale.'.txt'); // Aliases contain the text "%%ALIAS" followed by the aliased locale if (preg_match('/"%%ALIAS"\{"([^"]+)"\}/', $content, $matches)) { $aliases[$locale] = $matches[1]; } } return $aliases; } } __halt_compiler();----SIGNATURE:----hZWG9nAXL7pE3j6x9fr+N4FNQcqKNrv8YYNMsDY9lZI9kN7pTYpsu31vAwRIOvIKFBWkmeQ73QnU/kqb8m5rVCt/pND6KflTtREmHPEsZ3VePXPWMd56bV+a2eZjEJFmQSicojSlzTbuWR+oMVEvTodjQnej3lC4S4adTkQSHZdEnbG3IuEkAAqxJ86vuBwdLuXSz4Bm0Bw/A/wkhtciTmwD858O3ELGAwwMgvIpd2vcubkA4CK6N+AwsjvHu7C744Pbt9g7b+d6kkleUxQnMP9FHfx5nkw8JTmYaeZnC8uTfIULFXbgaCzPN14Kt3hlqSo8JgLLOz/NecvVMRTnzsYgdUBHl9EmAbL7HHqZHIF4mFgI+2tUsmMIgbhe5orZFKc7L1xY7Et9vw1yulTIg99b0PZILkwMMTl/SjQe1dLr3XvGhrg/fRyF8Bkv2wL+nxwJ2aRKgQ1rz1qHBU4IofXYIBFqCf45Aoxz89SwXlhL/3gh1JRJ7aTUYPcKPg04CXwmXSLGwOcs/xzTDa8TwwicoanwLiX7eWuWjoMAufY4LroW5UGcZi2XpFmPo8RH2adgFMVk0IRvMxKArhdFNIdn37faAbrjqC/5vA1cPCngB/4YHnu9Lzao702WrkwvHXsj5mmlDkIuu9agbE7fTH1j1WLDxi5Z1Yv5VD4awMY=----ATTACHMENT:----MzE4Mzk1NTQ5MDg5Mzg2OSA2Mzc2NTE4OTg1OTgwNTcyIDk4NDA0NzgwMTA5MzI4ODc=