Skip to content

Commit 5e44cfc

Browse files
Merge branch '5.4' into 6.4
* 5.4: [PhpUnitBridge][VarDumper] fix color detection [CI] Make sure we preserve file->header when we run sync-translations.php Review validators.sl.xlf
2 parents 2868d0d + 77b8c94 commit 5e44cfc

File tree

5 files changed

+43
-32
lines changed

5 files changed

+43
-32
lines changed

.github/sync-translations.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
require __DIR__.'/../vendor/autoload.php';
1414

15-
function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $domain)
15+
function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $domain, ?\DOMElement $header = null)
1616
{
1717
$dom = new \DOMDocument('1.0', 'utf-8');
1818
$dom->formatOutput = true;
@@ -27,6 +27,10 @@ function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $d
2727
$xliffFile->setAttribute('datatype', 'plaintext');
2828
$xliffFile->setAttribute('original', 'file.ext');
2929

30+
if (null !== $header) {
31+
mergeDom($dom, $xliffFile, $header);
32+
}
33+
3034
$xliffBody = $xliffFile->appendChild($dom->createElement('body'));
3135
foreach ($messages->all($domain) as $source => $target) {
3236
$translation = $dom->createElement('trans-unit');
@@ -62,6 +66,24 @@ function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $d
6266
return preg_replace('/^ +/m', '$0$0', $dom->saveXML());
6367
}
6468

69+
function mergeDom(\DOMDocument $dom, \DOMNode $tree, \DOMNode $input)
70+
{
71+
$new = $dom->createElement($input->tagName);
72+
foreach ($input->attributes as $key => $value) {
73+
$new->setAttribute($key, $value);
74+
}
75+
$tree->appendChild($new);
76+
foreach ($input->childNodes as $child) {
77+
if ($child instanceof \DOMText) {
78+
$new->appendChild($dom->createTextNode(str_replace(' ', ' ', $child->textContent)));
79+
} elseif ($child instanceof \DOMNode) {
80+
mergeDom($dom, $new, $child);
81+
} else {
82+
// We just need to update our script to handle this node types
83+
throw new \LogicException('Unsupported node type: '.get_class($child));
84+
}
85+
}
86+
}
6587

6688
foreach (['Security/Core' => 'security', 'Form' => 'validators', 'Validator' => 'validators'] as $component => $domain) {
6789
$dir = __DIR__.'/../src/Symfony/Component/'.$component.'/Resources/translations';
@@ -95,6 +117,13 @@ function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $d
95117
$localeCatalogue->setMetadata($source, $metadata, $domain);
96118
}
97119

98-
file_put_contents($file, dumpXliff1('en', $localeCatalogue, $domain));
120+
$inputDom = new \DOMDocument();
121+
$inputDom->loadXML(file_get_contents($file->getRealPath()));
122+
$header = null;
123+
if (1 === $inputDom->getElementsByTagName('header')->count()) {
124+
$header = $inputDom->getElementsByTagName('header')->item(0);
125+
}
126+
127+
file_put_contents($file, dumpXliff1('en', $localeCatalogue, $domain, $header));
99128
}
100129
}

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,10 @@ private static function hasColorSupport()
412412
}
413413

414414
if (!self::isTty()) {
415-
return true;
415+
return false;
416416
}
417417

418-
if ('\\' === \DIRECTORY_SEPARATOR
419-
&& \function_exists('sapi_windows_vt100_support')
420-
&& @sapi_windows_vt100_support(\STDOUT)
421-
) {
418+
if ('\\' === \DIRECTORY_SEPARATOR && \function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support(\STDOUT)) {
422419
return true;
423420
}
424421

src/Symfony/Component/Console/Output/StreamOutput.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ protected function hasColorSupport(): bool
9797
return false;
9898
}
9999

100-
if (!$this->isTty()) {
100+
// Detect msysgit/mingw and assume this is a tty because detection
101+
// does not work correctly, see https://github.com/composer/composer/issues/9690
102+
if (!@stream_isatty($this->stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
101103
return false;
102104
}
103105

@@ -120,21 +122,4 @@ protected function hasColorSupport(): bool
120122
// See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
121123
return preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
122124
}
123-
124-
/**
125-
* Checks if the stream is a TTY, i.e; whether the output stream is connected to a terminal.
126-
*
127-
* Reference: Composer\Util\Platform::isTty
128-
* https://github.com/composer/composer
129-
*/
130-
private function isTty(): bool
131-
{
132-
// Detect msysgit/mingw and assume this is a tty because detection
133-
// does not work correctly, see https://github.com/composer/composer/issues/9690
134-
if (\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
135-
return true;
136-
}
137-
138-
return @stream_isatty($this->stream);
139-
}
140125
}

src/Symfony/Component/Validator/Resources/translations/validators.sl.xlf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
</trans-unit>
137137
<trans-unit id="37" resname="This is not a valid IP address.">
138138
<source>This value is not a valid IP address.</source>
139-
<target state="needs-review-translation">Ta vrednost ni veljaven IP naslov.</target>
139+
<target>Ta vrednost ni veljaven IP naslov.</target>
140140
</trans-unit>
141141
<trans-unit id="38">
142142
<source>This value is not a valid language.</source>
@@ -192,7 +192,7 @@
192192
</trans-unit>
193193
<trans-unit id="51" resname="No temporary folder was configured in php.ini.">
194194
<source>No temporary folder was configured in php.ini, or the configured folder does not exist.</source>
195-
<target state="needs-review-translation">V php.ini ni bila nastavljena začasna mapa, ali nastavljena mapa ne obstaja.</target>
195+
<target>V php.ini ni bila nastavljena začasna mapa, ali pa nastavljena mapa ne obstaja.</target>
196196
</trans-unit>
197197
<trans-unit id="52">
198198
<source>Cannot write temporary file to disk.</source>
@@ -224,7 +224,7 @@
224224
</trans-unit>
225225
<trans-unit id="59" resname="This is not a valid International Bank Account Number (IBAN).">
226226
<source>This value is not a valid International Bank Account Number (IBAN).</source>
227-
<target state="needs-review-translation">Ta vrednost ni veljavna Mednarodna številka bančnega računa (IBAN).</target>
227+
<target>Ta vrednost ni veljavna mednarodna številka bančnega računa (IBAN).</target>
228228
</trans-unit>
229229
<trans-unit id="60">
230230
<source>This value is not a valid ISBN-10.</source>
@@ -312,15 +312,15 @@
312312
</trans-unit>
313313
<trans-unit id="81" resname="This is not a valid Business Identifier Code (BIC).">
314314
<source>This value is not a valid Business Identifier Code (BIC).</source>
315-
<target state="needs-review-translation">Ta vrednost ni veljavna Poslovna identifikacijska koda (BIC).</target>
315+
<target>Ta vrednost ni veljavna poslovna identifikacijska koda (BIC).</target>
316316
</trans-unit>
317317
<trans-unit id="82">
318318
<source>Error</source>
319319
<target>Napaka</target>
320320
</trans-unit>
321321
<trans-unit id="83" resname="This is not a valid UUID.">
322322
<source>This value is not a valid UUID.</source>
323-
<target state="needs-review-translation">Ta vrednost ni veljaven UUID.</target>
323+
<target>Ta vrednost ni veljaven UUID.</target>
324324
</trans-unit>
325325
<trans-unit id="84">
326326
<source>This value should be a multiple of {{ compared_value }}.</source>
@@ -436,7 +436,7 @@
436436
</trans-unit>
437437
<trans-unit id="112">
438438
<source>This value is not a valid MAC address.</source>
439-
<target state="needs-review-translation">Ta vrednost ni veljaven MAC naslov.</target>
439+
<target>Ta vrednost ni veljaven MAC naslov.</target>
440440
</trans-unit>
441441
</body>
442442
</file>

src/Symfony/Component/VarDumper/Dumper/CliDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ private function hasColorSupport(mixed $stream): bool
627627
// Detect msysgit/mingw and assume this is a tty because detection
628628
// does not work correctly, see https://github.com/composer/composer/issues/9690
629629
if (!@stream_isatty($stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
630-
return true;
630+
return false;
631631
}
632632

633633
if ('\\' === \DIRECTORY_SEPARATOR && @sapi_windows_vt100_support($stream)) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy