8set_error_handler(
function ($errno, $errstr, $errfile, $errline) {
 
    9    Enviro::echoErr(
"$errstr\nFile: $errfile\nLine: $errline\nCode: $errno\n");
 
   13require_once dirname(__DIR__).
'/src/autoloader.php';
 
   22            $language = Language::getById($languageId);
 
   23            if (!isset($language)) {
 
   24                throw new Exception(
"Unable to find the language with id '$languageId'");
 
   26            $languages[] = $language;
 
   29        $languages = Language::getAll();
 
   39} 
catch (Exception 
$x) {
 
   84        self::$outputUSAscii = 
false;
 
   85        self::$outputFormat = 
null;
 
   86        self::$outputFilename = 
null;
 
   87        self::$languages = 
null;
 
   89        $exporters = Exporter::getExporters();
 
   91            foreach (
$argv as $argi => $arg) {
 
   95                if (is_string($arg)) {
 
   96                    $argLC = trim(strtolower($arg));
 
   99                            self::$outputUSAscii = 
true;
 
  102                            self::$reduce = 
true;
 
  105                            self::$reduce = 
false;
 
  108                            if (preg_match(
'/^--output=.+$/', $argLC)) {
 
  109                                if (isset(self::$outputFilename)) {
 
  110                                    self::echoErr(
"The output file name has been specified more than once!\n");
 
  114                                list(, self::$outputFilename) = explode(
'=', $arg, 2);
 
  115                                self::$outputFilename = trim(self::$outputFilename);
 
  116                            } elseif (preg_match(
'/^--languages?=.+$/', $argLC)) {
 
  117                                list(, 
$s) = explode(
'=', $arg, 2);
 
  119                                if (is_array(self::$languages)) {
 
  120                                    self::$languages = array_merge(self::$languages, 
$list);
 
  122                                    self::$languages = 
$list;
 
  124                            } elseif (isset($exporters[$argLC])) {
 
  125                                if (isset(self::$outputFormat)) {
 
  126                                    self::echoErr(
"The output format has been specified more than once!\n");
 
  130                                self::$outputFormat = $argLC;
 
  141        if (!isset(self::$outputFormat)) {
 
  145        if (isset(self::$languages)) {
 
  146            self::$languages = array_values(array_unique(self::$languages));
 
  148        if (!isset(self::$reduce)) {
 
  149            self::$reduce = isset(self::$languages) ? false : 
true;
 
  158        $exporters = array_keys(Exporter::getExporters(
true));
 
  159        self::echoErr(
"Syntax: php ".basename(__FILE__).
" [--us-ascii] [--languages=<LanguageId>[,<LanguageId>,...]] [--reduce=yes|no] [--output=<file name>] <".implode(
'|', $exporters).
">\n");
 
  161        self::echoErr(
"--us-ascii : if specified, the output will contain only US-ASCII characters.\n");
 
  162        self::echoErr(
"--languages: (or --language) export only the specified language codes.\n");
 
  163        self::echoErr(
"             Separate languages with commas; you can also use this argument\n");
 
  164        self::echoErr(
"             more than once; it's case insensitive and accepts both '_' and\n");
 
  165        self::echoErr(
"             '-' as locale chunks separator (eg we accept 'it_IT' as well as\n");
 
  167        self::echoErr(
"--reduce   : if set to yes the output won't contain languages with the same\n");
 
  168        self::echoErr(
"             base language and rules.\n For instance nl_BE ('Flemish') will be\n");
 
  169        self::echoErr(
"             omitted because it's the same as nl ('Dutch').\n");
 
  170        self::echoErr(
"             Defaults to 'no' --languages is specified, to 'yes' otherwise.\n");
 
  171        self::echoErr(
"--output   : if specified, the output will be saved to <file name>. If not\n");
 
  172        self::echoErr(
"             specified we'll output to standard output.\n");
 
  174        $len = max(array_map(
'strlen', $exporters));
 
  175        foreach ($exporters as $exporter) {
 
  176            self::echoErr(str_pad($exporter, $len).
": ".Exporter::getExporterDescription($exporter).
"\n");
 
  185        $hStdErr = @fopen(
'php://stderr', 
'a');
 
  186        if ($hStdErr === 
false) {
 
  189            fwrite($hStdErr, $str);
 
  200        for ($numChunks = 3; $numChunks >= 2; $numChunks--) {
 
  203                $chunks = explode(
'_', $language->id);
 
  204                $compatibleFound = 
false;
 
  205                if (count($chunks) === $numChunks) {
 
  206                    $categoriesHash = serialize($language->categories);
 
  208                    $otherIds[] = $chunks[0];
 
  209                    for ($k = 2; $k < $numChunks; $k++) {
 
  210                        $otherIds[] = $chunks[0].
'_'.$chunks[$numChunks - 1];
 
  214                        foreach ($otherIds as $otherId) {
 
  215                            if (($check->id === $otherId) && ($check->formula === $language->formula) && (serialize($check->categories) === $categoriesHash)) {
 
  216                                $compatibleFound = 
true;
 
  220                        if ($compatibleFound === 
true) {
 
  225                if (!$compatibleFound) {
 
  226                    $filtered[] = $language;
 
An exception for terminatinating execution or to throw for unit testing.
Helper class to handle command line options.
static echoErr($str)
Print a string to stderr.
static initialize()
Parse the command line options.
static reduce($languages)
Reduce a language list to the minimum common denominator.
static showSyntax()
Write out the syntax.
Base class for all the exporters.
Main class to convert the plural rules of a language from CLDR to gettext.
if(isset($_REQUEST['delete'])) $list