Skip to content

Commit 100035a

Browse files
committed
Translations options
1 parent 6e18b9b commit 100035a

2 files changed

Lines changed: 20 additions & 14 deletions

File tree

src/Translations.php

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,21 @@ class Translations extends \ArrayObject
6060
const HEADER_PLURAL = 'Plural-Forms';
6161
const HEADER_DOMAIN = 'X-Domain';
6262

63-
public static $insertDate = true;
63+
public static $options = [
64+
'defaultHeaders' => [
65+
'Project-Id-Version' => '',
66+
'Report-Msgid-Bugs-To' => '',
67+
'Last-Translator' => '',
68+
'Language-Team' => '',
69+
'MIME-Version' => '1.0',
70+
'Content-Type' => 'text/plain; charset=UTF-8',
71+
'Content-Transfer-Encoding' => '8bit',
72+
],
73+
'defaultDateHeaders' => [
74+
'POT-Creation-Date',
75+
'PO-Revision-Date',
76+
]
77+
];
6478

6579
private $headers;
6680

@@ -69,21 +83,14 @@ class Translations extends \ArrayObject
6983
*/
7084
public function __construct($input = [], $flags = 0, $iterator_class = 'ArrayIterator')
7185
{
72-
$this->headers = [
73-
'Project-Id-Version' => '',
74-
'Report-Msgid-Bugs-To' => '',
75-
'Last-Translator' => '',
76-
'Language-Team' => '',
77-
'MIME-Version' => '1.0',
78-
'Content-Type' => 'text/plain; charset=UTF-8',
79-
'Content-Transfer-Encoding' => '8bit',
80-
];
86+
$this->headers = static::$options['defaultHeaders'];
8187

82-
if (static::$insertDate) {
83-
$this->headers['POT-Creation-Date'] = $this->headers['PO-Revision-Date'] = date('c');
88+
foreach (static::$options['defaultDateHeaders'] as $header) {
89+
$this->headers[$header] = date('c');
8490
}
8591

8692
$this->headers[self::HEADER_LANGUAGE] = '';
93+
8794
parent::__construct($input, $flags, $iterator_class);
8895
}
8996

tests/bootstrap.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
PHPUnit_Framework_Error_Notice::$enabled = true;
88

99
//Config
10-
Gettext\Translations::$insertDate = false;
11-
10+
Gettext\Translations::$options['defaultDateHeaders'] = [];
1211
Gettext\Generators\Jed::$options['json'] = JSON_PRETTY_PRINT;
1312
Gettext\Generators\Json::$options['json'] = JSON_PRETTY_PRINT;
1413
Gettext\Generators\JsonDictionary::$options['json'] = JSON_PRETTY_PRINT;

0 commit comments

Comments
 (0)