diff -r 000000000000 -r 7f95f8617b0b vendor/symfony/src/Symfony/Component/Locale/Resources/data/update-data.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/symfony/src/Symfony/Component/Locale/Resources/data/update-data.php Sat Sep 24 15:40:41 2011 +0200 @@ -0,0 +1,500 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +function bailout($message) +{ + exit($message."\n"); +} + +function check_dir($source) +{ + if (!file_exists($source)) { + bailout('The directory '.$source.' does not exist'); + } + + if (!is_dir($source)) { + bailout('The file '.$source.' is not a directory'); + } +} + +function check_command($command) +{ + exec('which '.$command, $output, $result); + + if ($result !== 0) { + bailout('The command "'.$command.'" is not installed'); + } +} + +function clear_directory($directory) +{ + $iterator = new \DirectoryIterator($directory); + + foreach ($iterator as $file) { + if (!$file->isDot()) { + if ($file->isDir()) { + clear_directory($file->getPathname()); + } else { + unlink($file->getPathname()); + } + } + } +} + +function make_directory($directory) +{ + if (!file_exists($directory)) { + mkdir($directory); + } + + if (!is_dir($directory)) { + bailout('The file '.$directory.' already exists but is no directory'); + } +} + +function list_files($directory, $extension) +{ + $files = array(); + $iterator = new \DirectoryIterator($directory); + + foreach ($iterator as $file) { + if (!$file->isDot() && substr($file->getFilename(), -strlen($extension)) === $extension) { + $files[] = substr($file->getFilename(), 0, -strlen($extension)); + } + } + + return $files; +} + +function genrb($source, $target) +{ + exec('genrb -d '.$target.' '.$source.DIRECTORY_SEPARATOR.'*.txt', $output, $result); + + if ($result !== 0) { + bailout('genrb failed'); + } +} + +function genrb_file($target, $source, $locale) +{ + exec('genrb -v -d '.$target.' '.$source.DIRECTORY_SEPARATOR.$locale.'.txt', $output, $result); + + if ($result !== 0) { + bailout('genrb failed'); + } +} + +function load_resource_bundle($locale, $directory) +{ + $bundle = \ResourceBundle::create($locale, $directory); + + if (null === $bundle) { + bailout('The resource bundle for locale '.$locale.' could not be loaded from directory '.$directory); + } + + return $bundle; +} + +function get_data($index, $dataDir, $locale = 'en', $constraint = null) +{ + $data = array(); + $bundle = load_resource_bundle($locale, __DIR__.DIRECTORY_SEPARATOR.$dataDir); + + foreach ($bundle->get($index) as $code => $name) { + if (null !== $constraint) { + if ($constraint($code)) { + $data[$code] = $name; + } + continue; + } + + $data[$code] = $name; + } + + $collator = new \Collator($locale); + $collator->asort($data); + + return $data; +} + +function create_stub_datafile($locale, $target, $data) { + $template = <<