1

I am using laravel localization

Here is the code I am using

<p class="retail-price">@lang('frontend/watch-detail.Reference.retail')
     <span class="prices">
     @if($watch['price'] == 0 || $watch['price'] == NULL) N/A

     @else
         @php
         $text =number_format($watch['price'], 0, ',', ' ');
         @endphp
         {{$text}}
     @endif
     </span>
</p>

Here is what I get in arabic =>Image that I get

While I should get 30 700!

I do not want to use a reverse function

2 Answers2

2

That issue occurs because Arabic is read from right to left. It would be easier to add an if statement to check if it is Arabic, then reverse it, so the reversed Arabic writing is reversed back to non-reversal.

Jack Bashford
  • 43,180
  • 11
  • 50
  • 79
2

You can wrap the text in a bdo element and define it as left-to-right:

function changeDir() {
  var el = document.getElementById('bdo0');
  el.dir = el.dir == 'ltr'? 'rtl':'ltr';
  document.getElementById('theDir').textContent = el.dir;
}
<div dir="rtl">هذا رقم: <bdo id="bdo0" dir="ltr">123 456 789</bdo></div>
<button onclick="changeDir()">Change direction</button><span id="theDir"></span>

You shouldn't need any in–page script, it should be just HTML.

RobG
  • 142,382
  • 31
  • 172
  • 209