🔧
This commit is contained in:
@@ -22,7 +22,7 @@ class CsvFileLoader extends FileLoader
|
||||
{
|
||||
private string $delimiter = ';';
|
||||
private string $enclosure = '"';
|
||||
private string $escape = '\\';
|
||||
private string $escape = '';
|
||||
|
||||
protected function loadResource(string $resource): array
|
||||
{
|
||||
@@ -55,7 +55,7 @@ class CsvFileLoader extends FileLoader
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCsvControl(string $delimiter = ';', string $enclosure = '"', string $escape = '\\')
|
||||
public function setCsvControl(string $delimiter = ';', string $enclosure = '"', string $escape = '')
|
||||
{
|
||||
$this->delimiter = $delimiter;
|
||||
$this->enclosure = $enclosure;
|
||||
|
||||
@@ -70,7 +70,7 @@ class IcuResFileLoader implements LoaderInterface
|
||||
* @param array $messages Used internally for recursive calls
|
||||
* @param string|null $path Current path being parsed, used internally for recursive calls
|
||||
*/
|
||||
protected function flatten(\ResourceBundle $rb, array &$messages = [], string $path = null): array
|
||||
protected function flatten(\ResourceBundle $rb, array &$messages = [], ?string $path = null): array
|
||||
{
|
||||
foreach ($rb as $key => $value) {
|
||||
$nodePath = $path ? $path.'.'.$key : $key;
|
||||
|
||||
@@ -112,12 +112,20 @@ class XliffFileLoader implements LoaderInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
$source = isset($attributes['resname']) && $attributes['resname'] ? $attributes['resname'] : $translation->source;
|
||||
$source = (string) (isset($attributes['resname']) && $attributes['resname'] ? $attributes['resname'] : $translation->source);
|
||||
|
||||
if (isset($translation->target)
|
||||
&& 'needs-translation' === (string) $translation->target->attributes()['state']
|
||||
&& \in_array((string) $translation->target, [$source, (string) $translation->source], true)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the xlf file has another encoding specified, try to convert it because
|
||||
// simple_xml will always return utf-8 encoded values
|
||||
$target = $this->utf8ToCharset((string) ($translation->target ?? $translation->source), $encoding);
|
||||
|
||||
$catalogue->set((string) $source, $target, $domain);
|
||||
$catalogue->set($source, $target, $domain);
|
||||
|
||||
$metadata = [
|
||||
'source' => (string) $translation->source,
|
||||
@@ -140,7 +148,7 @@ class XliffFileLoader implements LoaderInterface
|
||||
$metadata['id'] = (string) $attributes['id'];
|
||||
}
|
||||
|
||||
$catalogue->setMetadata((string) $source, $metadata, $domain);
|
||||
$catalogue->setMetadata($source, $metadata, $domain);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,7 +199,7 @@ class XliffFileLoader implements LoaderInterface
|
||||
/**
|
||||
* Convert a UTF8 string to the specified encoding.
|
||||
*/
|
||||
private function utf8ToCharset(string $content, string $encoding = null): string
|
||||
private function utf8ToCharset(string $content, ?string $encoding = null): string
|
||||
{
|
||||
if ('UTF-8' !== $encoding && !empty($encoding)) {
|
||||
return mb_convert_encoding($content, $encoding, 'UTF-8');
|
||||
@@ -200,7 +208,7 @@ class XliffFileLoader implements LoaderInterface
|
||||
return $content;
|
||||
}
|
||||
|
||||
private function parseNotesMetadata(\SimpleXMLElement $noteElement = null, string $encoding = null): array
|
||||
private function parseNotesMetadata(?\SimpleXMLElement $noteElement = null, ?string $encoding = null): array
|
||||
{
|
||||
$notes = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user