Skip to content

Commit

Permalink
[FIX] Fixed translations
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed Dec 22, 2024
1 parent 80476a1 commit 32cecff
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 40 deletions.
19 changes: 13 additions & 6 deletions src/ZugferdVisualizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,42 +122,49 @@ class ZugferdVisualizer
*
* @param ZugferdDocumentReader $documentReader
* @param ZugferdVisualizerMarkupRendererContract|null $renderer
* @param ZugferdVisualizerTranslatorContract|null $translator
* @return ZugferdVisualizer
*/
public static function fromDocumentReader(ZugferdDocumentReader $documentReader, ?ZugferdVisualizerMarkupRendererContract $renderer = null): ZugferdVisualizer
public static function fromDocumentReader(ZugferdDocumentReader $documentReader, ?ZugferdVisualizerMarkupRendererContract $renderer = null, ?ZugferdVisualizerTranslatorContract $translator = null): ZugferdVisualizer
{
return new ZugferdVisualizer($documentReader, $renderer);
return new ZugferdVisualizer($documentReader, $renderer, $translator);
}

/**
* Factory for creating a visualizer by a ZugferdDocumentReader
*
* @param ZugferdDocumentBuilder $documentBuilder
* @param ZugferdVisualizerMarkupRendererContract|null $renderer
* @param ZugferdVisualizerTranslatorContract|null $translator
* @return ZugferdVisualizer
*/
public static function fromDocumentBuilder(ZugferdDocumentBuilder $documentBuilder, ?ZugferdVisualizerMarkupRendererContract $renderer = null): ZugferdVisualizer
public static function fromDocumentBuilder(ZugferdDocumentBuilder $documentBuilder, ?ZugferdVisualizerMarkupRendererContract $renderer = null, ?ZugferdVisualizerTranslatorContract $translator = null): ZugferdVisualizer
{
$documentReader = ZugferdDocumentReader::readAndGuessFromContent($documentBuilder->getContent());

return static::fromDocumentReader($documentReader, $renderer);
return static::fromDocumentReader($documentReader, $renderer, $translator);
}

/**
* Constructor
*
* @param ZugferdDocumentReader $documentReader
* @param null|ZugferdVisualizerMarkupRendererContract $renderer
* @param ZugferdVisualizerMarkupRendererContract|null $renderer
* @param ZugferdVisualizerTranslatorContract|null $translator
* @return void
* @deprecated v2.0.0 Direct call of constructor will be removed in the future. Use static factory methods instead
*/
public function __construct(ZugferdDocumentReader $documentReader, ?ZugferdVisualizerMarkupRendererContract $renderer = null)
public function __construct(ZugferdDocumentReader $documentReader, ?ZugferdVisualizerMarkupRendererContract $renderer = null, ?ZugferdVisualizerTranslatorContract $translator = null)
{
$this->documentReader = $documentReader;

if ($renderer) {
$this->setRenderer($renderer);
}

if ($translator) {
$this->setTranslator($translator);
}
}

/**
Expand Down
20 changes: 10 additions & 10 deletions tests/assets/de-AT.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

return [
'unitcodes' => [
'H87' => 'S.',
],
'documenttype' => [
'380' => 'Rchng',
],
];
<?php

return [
'unitcodes' => [
'H87' => 'S.',
],
'documenttype' => [
'380' => 'Rchng',
],
];
28 changes: 14 additions & 14 deletions tests/assets/de-DE.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

return [
'unitcodes' => [
'H87' => 'St.',
],
'documenttype' => [
'380' => 'Rechnungsbeleg',
],
'general' => [
'greeting' => 'Hello :name',
'greeting2' => 'Hello {{name}}',
],
];
<?php

return [
'unitcodes' => [
'H87' => 'St.',
],
'documenttype' => [
'380' => 'Rechnungsbeleg',
],
'general' => [
'greeting' => 'Hello :name',
'greeting2' => 'Hello {{name}}',
],
];
20 changes: 10 additions & 10 deletions tests/assets/en.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

return [
'unitcodes' => [
'H87' => 'Piece',
],
'documenttype' => [
'380' => 'Invoice',
],
];
<?php

return [
'unitcodes' => [
'H87' => 'Piece',
],
'documenttype' => [
'380' => 'Invoice',
],
];

0 comments on commit 32cecff

Please sign in to comment.