diff --git a/src/Generator/MoGenerator.php b/src/Generator/MoGenerator.php index 55815822..5edb68e0 100644 --- a/src/Generator/MoGenerator.php +++ b/src/Generator/MoGenerator.php @@ -67,7 +67,7 @@ public function generateString(Translations $translations): string $originalsIndex[] = [ 'relativeOffset' => strlen($originalsTable), - 'length' => strlen($originalString), + 'length' => strlen((string) $originalString), ]; $originalsTable .= $originalString."\x00"; $translationsIndex[] = [ diff --git a/tests/MoGeneratorTest.php b/tests/MoGeneratorTest.php index 2e1eff62..06b3f5d9 100644 --- a/tests/MoGeneratorTest.php +++ b/tests/MoGeneratorTest.php @@ -23,7 +23,7 @@ public function testMoGenerator() ->set('X-Generator', 'PHP-Gettext'); $translation = Translation::create('context-1', 'Original'); - $translation->translate('Orixintal'); + $translation->translate('Orixinal'); $translations->add($translation); $translation = Translation::create('context-1', 'Other comment', 'Other comments'); @@ -36,6 +36,10 @@ public function testMoGenerator() $translation->translate('Comentario deshabilitado'); $translations->add($translation); + $translation = Translation::create(null, '123456'); + $translation->translate('12345'); + $translations->add($translation); + $mo = $generator->generateString($translations); $expected = file_get_contents(__DIR__.'/assets/mo-generator-result.mo'); @@ -43,7 +47,7 @@ public function testMoGenerator() $result = $loader->loadString($mo); - $this->assertCount(2, $result); + $this->assertCount(3, $result); $this->assertCount(5, $result->getHeaders()); } } diff --git a/tests/assets/mo-generator-result.mo b/tests/assets/mo-generator-result.mo index f055a073..cc7feb7c 100644 Binary files a/tests/assets/mo-generator-result.mo and b/tests/assets/mo-generator-result.mo differ