I'm using PHPWord template processor to insert some text in a template.
The word template is formatted LTR as all the labels are English.
Here is the line in the word template:
User Name: ${name}
Here is the PHP line that replaces the value:
$template->setValue('name', $user->name);
The sentence is bidirectional. The label is English (LTR) and the username is always Arabic (RTL).
Here is the generated line of code in document.xml, after unzipping the word file:
<w:r><w:rPr><w:b/><w:bCs/><w:lang w:val="en-US" w:bidi="ar-EG"/></w:rPr><w:t>User Name:</w:t></w:r><w:r><w:rPr><w:lang w:val="en-US" w:bidi="ar-EG"/></w:rPr><w:t xml:space="preserve"> عمرو هشام</w:t><w:tab/></w:r>
The replaced text appears correctly RTL in LibreOffice, but appears LTR (reversed) in Microsoft Word.
What can I do to make it appear correctly (RTL) in Microsoft Word ?