From f8dfb012d4b10cd546021f165ad3b0c90d365318 Mon Sep 17 00:00:00 2001 From: pedro-mendonca Date: Wed, 24 Jul 2024 18:44:44 +0100 Subject: [PATCH 1/3] Move numbers before words in string sorting on the .mo test file --- tests/assets/mo-generator-result.mo | Bin 317 -> 339 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/tests/assets/mo-generator-result.mo b/tests/assets/mo-generator-result.mo index cc7feb7c2adcc529dadfbe2606c928642a39de15..b717abe3bceb460c076d31925cfbb2cbe8eeb641 100644 GIT binary patch delta 151 zcmdnXbeXCCo)F7a1|VPsVi_QI0dasJ2SR~qHXu6}h?#)61c-%zxEzSZfw&8Zdx3Zn z5QEGxV1%eM1JWEoz9o*u>O~!O)Z;IX|x?wW36KVyg1Q{yq+{1WpAs{;zh{b`p0EpRuxC4lLfw&)tIe=J} zk%2(~NUH&9Rv>K-q$if?uo)T|o0ytST-dMRUzAyqnU|Qu;9pu&l&_GSpPQOjl30|P J&j41#007HE7RCSo From 425d25442fe28ea39f6be9ebc28703876b8e91f3 Mon Sep 17 00:00:00 2001 From: pedro-mendonca Date: Wed, 24 Jul 2024 18:45:46 +0100 Subject: [PATCH 2/3] Add original string "15" --- tests/MoGeneratorTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/MoGeneratorTest.php b/tests/MoGeneratorTest.php index 06b3f5d9..a3e246dc 100644 --- a/tests/MoGeneratorTest.php +++ b/tests/MoGeneratorTest.php @@ -36,6 +36,10 @@ public function testMoGenerator() $translation->translate('Comentario deshabilitado'); $translations->add($translation); + $translation = Translation::create(null, '15'); + $translation->translate('15'); + $translations->add($translation); + $translation = Translation::create(null, '123456'); $translation->translate('12345'); $translations->add($translation); @@ -47,7 +51,7 @@ public function testMoGenerator() $result = $loader->loadString($mo); - $this->assertCount(3, $result); + $this->assertCount(4, $result); $this->assertCount(5, $result->getHeaders()); } } From b8bc1868479484eca7737340d24dff08e4df78f7 Mon Sep 17 00:00:00 2001 From: pedro-mendonca Date: Wed, 24 Jul 2024 18:47:56 +0100 Subject: [PATCH 3/3] Sort by key comparing as strings --- src/Generator/MoGenerator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generator/MoGenerator.php b/src/Generator/MoGenerator.php index 5edb68e0..e8151016 100644 --- a/src/Generator/MoGenerator.php +++ b/src/Generator/MoGenerator.php @@ -45,7 +45,7 @@ public function generateString(Translations $translations): string $messages[$originalString] = $translation; } - ksort($messages); + ksort($messages, SORT_STRING); $numEntries = count($messages); $originalsTable = ''; $translationsTable = '';