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 @@ -548,6 +548,18 @@ public function testVueJs2MultipleDomainScanning()
548548 }
549549 }
550550
551+ public function testVueJsUtf8Scanning ()
552+ {
553+ $ translations = new Translations ();
554+
555+ VueJs::fromFile (static ::asset ('vuejs3/input.vue ' ), $ translations );
556+
557+ self ::assertCount (2 , $ translations );
558+
559+ self ::assertNotFalse ($ translations ->find ('' , 'Let’s test ā ūtf8 štriņģ ❤️ ' ));
560+ self ::assertNotFalse ($ translations ->find ('' , 'We’re happy to have you here, 愛 ' ));
561+ }
562+
551563 public function testXliffUnitIds ()
552564 {
553565 $ 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