File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,7 +165,10 @@ protected static function convertHtmlToDom($html)
165165 $ dom = new DOMDocument ;
166166
167167 libxml_use_internal_errors (true );
168- $ dom ->loadHTML ($ html );
168+
169+ // Prepend xml encoding so DOMDocument document handles UTF8 correctly.
170+ // Assuming that vue template files will not have any xml encoding tags, because duplicate tags may be ignored.
171+ $ dom ->loadHTML ('<?xml encoding="utf-8"?> ' . $ html );
169172
170173 libxml_clear_errors ();
171174
Original file line number Diff line number Diff line change @@ -557,6 +557,18 @@ public function testMissingDomainScanWithOtherStringsInFile()
557557 self ::assertCount (0 , $ translations );
558558 }
559559
560+ public function testVueJsUtf8Scanning ()
561+ {
562+ $ translations = new Translations ();
563+
564+ VueJs::fromFile (static ::asset ('vuejs3/input.vue ' ), $ translations );
565+
566+ self ::assertCount (2 , $ translations );
567+
568+ self ::assertNotFalse ($ translations ->find ('' , 'Let’s test ā ūtf8 štriņģ 😎️ ' ));
569+ self ::assertNotFalse ($ translations ->find ('' , 'We’re happy to have you here, 愛 ' ));
570+ }
571+
560572 public function testXliffUnitIds ()
561573 {
562574 $ translations = static ::get ('xliff/Xliff ' , 'Xliff ' , ['unitid_as_id ' => true ]);
Original file line number Diff line number Diff line change 1+ <template >
2+ {{ __('Let’s test ā ūtf8 štriņģ 😎️') }}
3+ </template >
4+
5+ <script >
6+ export default {
7+ computed: {
8+ buttonText () {
9+ return __ (' We’re happy to have you here, 愛' );
10+ }
11+ },
12+ }
13+ </script >
You can’t perform that action at this time.
0 commit comments