Helper class to handle command line options.
More...
Helper class to handle command line options.
Definition at line 51 of file export-plural-rules.php.
◆ echoErr() [1/2]
static Enviro::echoErr |
( |
|
$str | ) |
|
|
static |
Print a string to stderr.
- Parameters
-
string | $str | The string to be printed out. |
Definition at line 183 of file export-plural-rules.php.
185 $hStdErr = @fopen(
'php://stderr',
'a');
186 if ($hStdErr ===
false) {
189 fwrite($hStdErr, $str);
◆ echoErr() [2/2]
static Enviro::echoErr |
( |
|
$str | ) |
|
|
static |
Print a string to stderr.
- Parameters
-
string | $str | The string to be printed out. |
Definition at line 183 of file export-plural-rules.php.
185 $hStdErr = @fopen(
'php://stderr',
'a');
186 if ($hStdErr ===
false) {
189 fwrite($hStdErr, $str);
◆ initialize() [1/2]
static Enviro::initialize |
( |
| ) |
|
|
static |
Parse the command line options.
Definition at line 81 of file export-plural-rules.php.
References $argv, $list, and $s.
84 self::$outputUSAscii =
false;
85 self::$outputFormat = null;
86 self::$outputFilename = null;
87 self::$languages = null;
89 $exporters = Exporter::getExporters();
90 if (isset($argv) && is_array($argv)) {
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;
132 self::echoErr(
"Unknown option: $arg\n");
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;
if(isset($_REQUEST['delete'])) $list
◆ initialize() [2/2]
static Enviro::initialize |
( |
| ) |
|
|
static |
Parse the command line options.
Definition at line 81 of file export-plural-rules.php.
References $argv, $list, and $s.
84 self::$outputUSAscii =
false;
85 self::$outputFormat = null;
86 self::$outputFilename = null;
87 self::$languages = null;
89 $exporters = Exporter::getExporters();
90 if (isset($argv) && is_array($argv)) {
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;
132 self::echoErr(
"Unknown option: $arg\n");
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;
if(isset($_REQUEST['delete'])) $list
◆ reduce() [1/2]
static Enviro::reduce |
( |
|
$languages | ) |
|
|
static |
Reduce a language list to the minimum common denominator.
- Parameters
-
- Returns
- Language[]
Definition at line 198 of file export-plural-rules.php.
References $languages, and array.
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;
Create styles array
The data for the language used.
◆ reduce() [2/2]
static Enviro::reduce |
( |
|
$languages | ) |
|
|
static |
Reduce a language list to the minimum common denominator.
- Parameters
-
- Returns
- Language[]
Definition at line 198 of file export-plural-rules.php.
References $languages, and array.
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;
Create styles array
The data for the language used.
◆ showSyntax() [1/2]
static Enviro::showSyntax |
( |
| ) |
|
|
static |
Write out the syntax.
Definition at line 156 of file export-plural-rules.php.
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");
160 self::echoErr(
"Where:\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");
166 self::echoErr(
" 'it-it').\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");
173 self::echoErr(
"Output formats\n");
174 $len = max(array_map(
'strlen', $exporters));
175 foreach ($exporters as $exporter) {
176 self::echoErr(str_pad($exporter, $len).
": ".Exporter::getExporterDescription($exporter).
"\n");
◆ showSyntax() [2/2]
static Enviro::showSyntax |
( |
| ) |
|
|
static |
Write out the syntax.
Definition at line 156 of file export-plural-rules.php.
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");
160 self::echoErr(
"Where:\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");
166 self::echoErr(
" 'it-it').\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");
173 self::echoErr(
"Output formats\n");
174 $len = max(array_map(
'strlen', $exporters));
175 foreach ($exporters as $exporter) {
176 self::echoErr(str_pad($exporter, $len).
": ".Exporter::getExporterDescription($exporter).
"\n");
◆ $languages
static Enviro::$languages |
|
static |
◆ $outputFilename
static Enviro::$outputFilename |
|
static |
◆ $outputFormat
static Enviro::$outputFormat |
|
static |
◆ $outputUSAscii
static Enviro::$outputUSAscii |
|
static |
◆ $reduce
The documentation for this class was generated from the following file: