From 32cecff61e4ef42f171d8fe8b9f8a2e954014781 Mon Sep 17 00:00:00 2001 From: HorstOeko Date: Mon, 23 Dec 2024 00:32:53 +0100 Subject: [PATCH] [FIX] Fixed translations --- src/ZugferdVisualizer.php | 19 +++++++++++++------ tests/assets/de-AT.php | 20 ++++++++++---------- tests/assets/de-DE.php | 28 ++++++++++++++-------------- tests/assets/en.php | 20 ++++++++++---------- 4 files changed, 47 insertions(+), 40 deletions(-) diff --git a/src/ZugferdVisualizer.php b/src/ZugferdVisualizer.php index 1067ca1..11470e7 100644 --- a/src/ZugferdVisualizer.php +++ b/src/ZugferdVisualizer.php @@ -122,11 +122,12 @@ 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); } /** @@ -134,30 +135,36 @@ public static function fromDocumentReader(ZugferdDocumentReader $documentReader, * * @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); + } } /** diff --git a/tests/assets/de-AT.php b/tests/assets/de-AT.php index aa25305..40d7556 100644 --- a/tests/assets/de-AT.php +++ b/tests/assets/de-AT.php @@ -1,10 +1,10 @@ - [ - 'H87' => 'S.', - ], - 'documenttype' => [ - '380' => 'Rchng', - ], -]; + [ + 'H87' => 'S.', + ], + 'documenttype' => [ + '380' => 'Rchng', + ], +]; diff --git a/tests/assets/de-DE.php b/tests/assets/de-DE.php index e965117..e5c2f51 100644 --- a/tests/assets/de-DE.php +++ b/tests/assets/de-DE.php @@ -1,14 +1,14 @@ - [ - 'H87' => 'St.', - ], - 'documenttype' => [ - '380' => 'Rechnungsbeleg', - ], - 'general' => [ - 'greeting' => 'Hello :name', - 'greeting2' => 'Hello {{name}}', - ], -]; + [ + 'H87' => 'St.', + ], + 'documenttype' => [ + '380' => 'Rechnungsbeleg', + ], + 'general' => [ + 'greeting' => 'Hello :name', + 'greeting2' => 'Hello {{name}}', + ], +]; diff --git a/tests/assets/en.php b/tests/assets/en.php index b61d1ef..4397741 100644 --- a/tests/assets/en.php +++ b/tests/assets/en.php @@ -1,10 +1,10 @@ - [ - 'H87' => 'Piece', - ], - 'documenttype' => [ - '380' => 'Invoice', - ], -]; + [ + 'H87' => 'Piece', + ], + 'documenttype' => [ + '380' => 'Invoice', + ], +];