@@ -559,7 +559,6 @@ public function testReadForOneLocaleAndOneDomain(string $locale, string $domain,
559
559
$ expectedBody = json_encode ([
560
560
'format ' => 'symfony_xliff ' ,
561
561
'original_filenames ' => true ,
562
- 'directory_prefix ' => '%LANG_ISO% ' ,
563
562
'filter_langs ' => [$ locale ],
564
563
'filter_filenames ' => [$ domain .'.xliff ' ],
565
564
'export_empty_as ' => 'skip ' ,
@@ -581,15 +580,10 @@ public function testReadForOneLocaleAndOneDomain(string $locale, string $domain,
581
580
]));
582
581
};
583
582
584
- $ loader = $ this ->getLoader ();
585
- $ loader ->expects ($ this ->once ())
586
- ->method ('load ' )
587
- ->willReturn ((new XliffFileLoader ())->load ($ responseContent , $ locale , $ domain ));
588
-
589
583
$ provider = self ::createProvider ((new MockHttpClient ($ response ))->withOptions ([
590
584
'base_uri ' => 'https://api.lokalise.com/api2/projects/PROJECT_ID/ ' ,
591
585
'headers ' => ['X-Api-Token ' => 'API_KEY ' ],
592
- ]), $ loader , $ this ->getLogger (), $ this ->getDefaultLocale (), 'api.lokalise.com ' );
586
+ ]), new XliffFileLoader () , $ this ->getLogger (), $ this ->getDefaultLocale (), 'api.lokalise.com ' );
593
587
$ translatorBag = $ provider ->read ([$ domain ], [$ locale ]);
594
588
595
589
// We don't want to assert equality of metadata here, due to the ArrayLoader usage.
@@ -761,6 +755,36 @@ public static function getResponsesForOneLocaleAndOneDomain(): \Generator
761
755
$ expectedTranslatorBagEn ,
762
756
];
763
757
758
+ $ expectedTranslatorBagEnUS = new TranslatorBag ();
759
+ $ expectedTranslatorBagEnUS ->addCatalogue ($ arrayLoader ->load ([
760
+ 'index.hello ' => 'Hello ' ,
761
+ 'index.greetings ' => 'Welcome, {firstname}! ' ,
762
+ ], 'en_US ' ));
763
+
764
+ yield ['en_US ' , 'messages ' , <<<'XLIFF'
765
+ <?xml version="1.0" encoding="UTF-8"?>
766
+ <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd">
767
+ <file original="" datatype="plaintext" xml:space="preserve" source-language="en" target-language="en-US">
768
+ <header>
769
+ <tool tool-id="lokalise.com" tool-name="Lokalise"/>
770
+ </header>
771
+ <body>
772
+ <trans-unit id="index.greetings" resname="index.greetings">
773
+ <source>index.greetings</source>
774
+ <target>Welcome, {firstname}!</target>
775
+ </trans-unit>
776
+ <trans-unit id="index.hello" resname="index.hello">
777
+ <source>index.hello</source>
778
+ <target>Hello</target>
779
+ </trans-unit>
780
+ </body>
781
+ </file>
782
+ </xliff>
783
+ XLIFF
784
+ ,
785
+ $ expectedTranslatorBagEnUS ,
786
+ ];
787
+
764
788
$ expectedTranslatorBagFr = new TranslatorBag ();
765
789
$ expectedTranslatorBagFr ->addCatalogue ($ arrayLoader ->load ([
766
790
'index.hello ' => 'Bonjour ' ,
0 commit comments