mirror of
https://github.com/itflow-org/itflow
synced 2026-09-22 14:41:17 +00:00
Bump imapengine from 1.25.4 to 1.25.6 and dependencies
This commit is contained in:
@@ -153,7 +153,7 @@ class XliffLintCommand extends Command
|
||||
libxml_clear_errors();
|
||||
libxml_use_internal_errors($internal);
|
||||
|
||||
return ['file' => $file, 'valid' => 0 === \count($errors), 'messages' => $errors];
|
||||
return ['file' => $file, 'valid' => !$errors, 'messages' => $errors];
|
||||
}
|
||||
|
||||
private function display(SymfonyStyle $io, array $files): int
|
||||
|
||||
@@ -30,6 +30,8 @@ class PoFileDumper extends FileDumper
|
||||
$output .= "\n";
|
||||
|
||||
$newLine = false;
|
||||
$isIntlDomain = str_ends_with($domain, MessageCatalogue::INTL_DOMAIN_SUFFIX);
|
||||
|
||||
foreach ($messages->all($domain) as $source => $target) {
|
||||
if ($newLine) {
|
||||
$output .= "\n";
|
||||
@@ -48,9 +50,10 @@ class PoFileDumper extends FileDumper
|
||||
$output .= $this->formatComments(implode(' ', (array) $metadata['sources']), ':');
|
||||
}
|
||||
|
||||
$sourceRules = $this->getStandardRules($source);
|
||||
$targetRules = $this->getStandardRules($target);
|
||||
if (2 == \count($sourceRules) && [] !== $targetRules) {
|
||||
// in an ICU domain the pipe is an ordinary character, pluralization is expressed by the message itself
|
||||
$sourceRules = $isIntlDomain ? [] : $this->getStandardRules($source);
|
||||
$targetRules = $isIntlDomain ? [] : $this->getStandardRules($target);
|
||||
if (2 == \count($sourceRules) && $targetRules) {
|
||||
$output .= \sprintf('msgid "%s"'."\n", $this->escape($sourceRules[0]));
|
||||
$output .= \sprintf('msgid_plural "%s"'."\n", $this->escape($sourceRules[1]));
|
||||
foreach ($targetRules as $i => $targetRule) {
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Symfony\Component\Translation\Extractor\Visitor;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\NodeVisitor;
|
||||
use Symfony\Component\Translation\TranslatableMessage;
|
||||
|
||||
/**
|
||||
* @author Mathieu Santostefano <msantostefano@protonmail.com>
|
||||
@@ -39,7 +40,9 @@ final class TranslatableMessageVisitor extends AbstractVisitor implements NodeVi
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!\in_array('TranslatableMessage', $className->getParts(), true)) {
|
||||
// the name resolver gives a fully qualified name; templates without a "use"
|
||||
// statement resolve to the global namespace, which is accepted as well
|
||||
if (!\in_array($className->toString(), [TranslatableMessage::class, 'TranslatableMessage'], true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,23 +31,19 @@ class CsvFileLoader extends FileLoader
|
||||
{
|
||||
$messages = [];
|
||||
|
||||
try {
|
||||
$file = new \SplFileObject($resource, 'rb');
|
||||
} catch (\RuntimeException $e) {
|
||||
throw new NotFoundResourceException(\sprintf('Error opening file "%s".', $resource), 0, $e);
|
||||
if (!$file = @fopen($resource, 'r')) {
|
||||
throw new NotFoundResourceException(\sprintf('Error opening file "%s".', $resource));
|
||||
}
|
||||
|
||||
$file->setFlags(\SplFileObject::READ_CSV | \SplFileObject::SKIP_EMPTY | \SplFileObject::DROP_NEW_LINE);
|
||||
$file->setCsvControl($this->delimiter, $this->enclosure, $this->escape);
|
||||
|
||||
foreach ($file as $data) {
|
||||
if (false === $data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!str_starts_with($data[0], '#') && isset($data[1]) && 2 === \count($data)) {
|
||||
$messages[$data[0]] = $data[1];
|
||||
try {
|
||||
while (false !== $data = fgetcsv($file, null, $this->delimiter, $this->enclosure, $this->escape)) {
|
||||
// empty lines are read as [null]
|
||||
if (isset($data[1]) && 2 === \count($data) && !str_starts_with($data[0], '#')) {
|
||||
$messages[$data[0]] = $data[1];
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
fclose($file);
|
||||
}
|
||||
|
||||
return $messages;
|
||||
|
||||
@@ -55,6 +55,7 @@ class PoFileLoader extends FileLoader
|
||||
* - No support for comments spanning multiple lines.
|
||||
* - Translator and extracted comments are treated as being the same type.
|
||||
* - Message IDs are allowed to have other encodings as just US-ASCII.
|
||||
* - Contexts (msgctxt) are parsed but discarded.
|
||||
*
|
||||
* Items with an empty id are ignored.
|
||||
*/
|
||||
@@ -65,6 +66,7 @@ class PoFileLoader extends FileLoader
|
||||
$defaults = [
|
||||
'ids' => [],
|
||||
'translated' => null,
|
||||
'context' => null,
|
||||
];
|
||||
|
||||
$messages = [];
|
||||
@@ -76,23 +78,28 @@ class PoFileLoader extends FileLoader
|
||||
|
||||
if ('' === $line) {
|
||||
// Whitespace indicated current item is done
|
||||
if (!\in_array('fuzzy', $flags, true)) {
|
||||
$this->addMessage($messages, $item);
|
||||
}
|
||||
$item = $defaults;
|
||||
$flags = [];
|
||||
$this->saveItem($messages, $item, $flags, $defaults);
|
||||
} elseif (str_starts_with($line, '#,')) {
|
||||
// flags belong to the next entry, so the previous one ends here
|
||||
if (null !== $item['translated']) {
|
||||
$this->saveItem($messages, $item, $flags, $defaults);
|
||||
}
|
||||
$flags = array_map('trim', explode(',', substr($line, 2)));
|
||||
} elseif (str_starts_with($line, 'msgctxt "')) {
|
||||
if (null !== $item['translated']) {
|
||||
$this->saveItem($messages, $item, $flags, $defaults);
|
||||
}
|
||||
$item['context'] = substr($line, 9, -1);
|
||||
} elseif (str_starts_with($line, 'msgid "')) {
|
||||
// We start a new msg so save previous
|
||||
// TODO: this fails when comments or contexts are added
|
||||
$this->addMessage($messages, $item);
|
||||
$item = $defaults;
|
||||
if ($item['ids']) {
|
||||
$this->saveItem($messages, $item, $flags, $defaults);
|
||||
}
|
||||
$item['ids']['singular'] = substr($line, 7, -1);
|
||||
} elseif (str_starts_with($line, 'msgstr "')) {
|
||||
$item['translated'] = substr($line, 8, -1);
|
||||
} elseif ('"' === $line[0]) {
|
||||
$continues = isset($item['translated']) ? 'translated' : 'ids';
|
||||
$continues = isset($item['translated']) ? 'translated' : ($item['ids'] ? 'ids' : 'context');
|
||||
|
||||
if (\is_array($item[$continues])) {
|
||||
end($item[$continues]);
|
||||
@@ -108,14 +115,21 @@ class PoFileLoader extends FileLoader
|
||||
}
|
||||
}
|
||||
// save last item
|
||||
if (!\in_array('fuzzy', $flags, true)) {
|
||||
$this->addMessage($messages, $item);
|
||||
}
|
||||
$this->saveItem($messages, $item, $flags, $defaults);
|
||||
fclose($stream);
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
private function saveItem(array &$messages, array &$item, array &$flags, array $defaults): void
|
||||
{
|
||||
if (!\in_array('fuzzy', $flags, true)) {
|
||||
$this->addMessage($messages, $item);
|
||||
}
|
||||
$item = $defaults;
|
||||
$flags = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a translation item to the messages.
|
||||
*
|
||||
|
||||
@@ -218,7 +218,7 @@ function printTable($translations, $verboseOutput, bool $includeCompletedLanguag
|
||||
|
||||
if ($translation['translated'] > $translation['total']) {
|
||||
textColorRed();
|
||||
} elseif (count($translation['mismatches']) > 0) {
|
||||
} elseif ($translation['mismatches']) {
|
||||
textColorRed();
|
||||
} elseif ($translation['is_completed']) {
|
||||
textColorGreen();
|
||||
@@ -235,7 +235,7 @@ function printTable($translations, $verboseOutput, bool $includeCompletedLanguag
|
||||
textColorNormal();
|
||||
|
||||
$shouldBeClosed = false;
|
||||
if (true === $verboseOutput && count($translation['missingKeys']) > 0) {
|
||||
if ($verboseOutput && $translation['missingKeys']) {
|
||||
echo '| Missing Translations:'.\PHP_EOL;
|
||||
|
||||
foreach ($translation['missingKeys'] as $id => $content) {
|
||||
@@ -243,7 +243,7 @@ function printTable($translations, $verboseOutput, bool $includeCompletedLanguag
|
||||
}
|
||||
$shouldBeClosed = true;
|
||||
}
|
||||
if (true === $verboseOutput && count($translation['mismatches']) > 0) {
|
||||
if ($verboseOutput && $translation['mismatches']) {
|
||||
echo '| Mismatches between trans-unit id and source:'.\PHP_EOL;
|
||||
|
||||
foreach ($translation['mismatches'] as $id => $content) {
|
||||
|
||||
@@ -158,11 +158,18 @@ class XliffUtils
|
||||
*/
|
||||
private static function fixXmlLocation(string $schemaSource, string $xmlUri): string
|
||||
{
|
||||
$path = __DIR__.'/../Resources/schemas/xml.xsd';
|
||||
static $newPath;
|
||||
|
||||
if (0 === stripos($path, 'phar://')) {
|
||||
if ($tmpfile = tempnam(sys_get_temp_dir(), 'symfony')) {
|
||||
if (null === $newPath) {
|
||||
$path = __DIR__.'/../Resources/schemas/xml.xsd';
|
||||
|
||||
if (0 !== stripos($path, 'phar://')) {
|
||||
$newPath = self::getFileUrl($path);
|
||||
} elseif ($tmpfile = tempnam(sys_get_temp_dir(), 'symfony')) {
|
||||
copy($path, $tmpfile);
|
||||
register_shutdown_function(static function () use ($tmpfile) {
|
||||
@unlink($tmpfile);
|
||||
});
|
||||
$newPath = self::getFileUrl($tmpfile);
|
||||
} else {
|
||||
$parts = explode('/', '\\' === \DIRECTORY_SEPARATOR ? str_replace('\\', '/', $path) : $path);
|
||||
@@ -170,8 +177,6 @@ class XliffUtils
|
||||
$drive = '\\' === \DIRECTORY_SEPARATOR ? array_shift($parts).'/' : '';
|
||||
$newPath = 'phar:///'.$drive.implode('/', array_map('rawurlencode', $parts));
|
||||
}
|
||||
} else {
|
||||
$newPath = self::getFileUrl($path);
|
||||
}
|
||||
|
||||
return str_replace($xmlUri, $newPath, $schemaSource);
|
||||
|
||||
Reference in New Issue
Block a user