-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathPhp.php
More file actions
61 lines (57 loc) · 2.06 KB
/
Php.php
File metadata and controls
61 lines (57 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace Gettext\Languages\Exporter;
class Php extends Exporter
{
/**
* {@inheritdoc}
*
* @see \Gettext\Languages\Exporter\Exporter::getDescription()
*/
public static function getDescription()
{
return 'Build a PHP array';
}
/**
* {@inheritdoc}
*
* @see \Gettext\Languages\Exporter\Exporter::toStringDoWithOptions()
*/
protected static function toStringDoWithOptions($languages, array $options)
{
$lines = array();
$lines[] = '<?php';
$lines[] = 'return array(';
foreach ($languages as $lc) {
$lines[] = ' \'' . $lc->id . '\' => array(';
$lines[] = ' \'name\' => \'' . addslashes($lc->name) . '\',';
if (isset($lc->supersededBy)) {
$lines[] = ' \'supersededBy\' => \'' . $lc->supersededBy . '\',';
}
if (isset($lc->script)) {
$lines[] = ' \'script\' => \'' . addslashes($lc->script) . '\',';
}
if (isset($lc->territory)) {
$lines[] = ' \'territory\' => \'' . addslashes($lc->territory) . '\',';
}
if (isset($lc->baseLanguage)) {
$lines[] = ' \'baseLanguage\' => \'' . addslashes($lc->baseLanguage) . '\',';
}
$lines[] = ' \'formula\' => \'' . $lc->formula . '\',';
$lines[] = ' \'plurals\' => ' . count($lc->categories) . ',';
$catNames = array();
foreach ($lc->categories as $c) {
$catNames[] = "'{$c->id}'";
}
$lines[] = ' \'cases\' => array(' . implode(', ', $catNames) . '),';
$lines[] = ' \'examples\' => array(';
foreach ($lc->categories as $c) {
$lines[] = ' \'' . $c->id . '\' => \'' . $c->examples . '\',';
}
$lines[] = ' ),';
$lines[] = ' ),';
}
$lines[] = ');';
$lines[] = '';
return implode("\n", $lines);
}
}