@@ -79,6 +79,32 @@ public function generateFailTranslationsData(): array
7979 ];
8080 }
8181
82+ public function generateTranslationsDataWithQuotes (): array
83+ {
84+ return [
85+ [
86+ 'app ' ,
87+ 'de ' ,
88+ [
89+ 'test \'.id1 ' => [
90+ 'message ' => 'app: \'Test 1 \' on the (de) ' ,
91+ 'comment ' => 'Translate \'wisely! ' ,
92+ ],
93+ 'test. \'id2 \'' => [
94+ 'message ' => 'app: Test 1 \' on the (de) ' ,
95+ 'comment ' => 'Translate \'wisely! ' ,
96+ ],
97+ 'test."id3 ' => [
98+ 'message ' => 'app: "Test 2" on the (de) ' ,
99+ ],
100+ 'test."id4" ' => [
101+ 'message ' => 'app: Test 3" on the (de) ' ,
102+ ],
103+ ],
104+ ],
105+ ];
106+ }
107+
82108 protected function tearDown (): void
83109 {
84110 $ this ->cleanFiles ();
@@ -246,4 +272,18 @@ public function testReadMessages(string $category, string $locale, array $data):
246272 $ messages = $ messageSource ->getMessages ($ category , $ locale );
247273 $ this ->assertEquals ($ messages , $ referenceMessages );
248274 }
275+
276+ /**
277+ * @dataProvider generateTranslationsDataWithQuotes
278+ */
279+ public function testWriteQuotedString (string $ category , string $ locale , array $ data ): void
280+ {
281+ $ this ->path = sys_get_temp_dir () . DIRECTORY_SEPARATOR . 'translate_tests ' . uniqid ();
282+
283+ $ messageSource = new MessageSource ($ this ->path );
284+ $ messageSource ->write ($ category , $ locale , $ data );
285+ foreach ($ data as $ id => $ value ) {
286+ $ this ->assertEquals ($ messageSource ->getMessage ($ id , $ category , $ locale ), $ value ['message ' ]);
287+ }
288+ }
249289}
0 commit comments