In my array, I have the months written in English and the days of the week also in English.
I am trying to replace the English words with their Arabic equivalents at the corresponding index in the array. My code looks simple and clean, but for some reason, it is not working. I have tried using two replace functions.
// English
var en_months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
var en_days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']
// Arabic
var ar_months = ['كانون الثاني','شباط','آذار','نيسان','أيار','حزيران','تموز','آب','أيلول','تشرين الأول','تشرين الثاني','كانون الأول'];
var ar_days = ['الأحَد','الإثْنَين','الثَلاثاء','الأربَعاء','الخَميس','الجُمُعة','السَبْت']
// ACTION
jQuery("span.date").text(function(i, val) {
return val.replace(en_months, ar_months);
return val.replace(en_days, ar_days);
});
This is an example of the span:
<span class="date">Wednesday, October 7th, 2015</span>
There are multiple instances of this on the page.