Natasha_Rana Posted July 27, 2017 Share Posted July 27, 2017 If you try this link https://jsfiddle.net/u4bxz74c/10/. Later the result will be like this PART 1 <p id="posttextareadisplay"> <p class="ENGLISH">This is a samplasde textssss</p> <p class="ENGLISH"><b>فَإِذَا جَلَسْتَ فِي وَسَطِ الصلَاةِ فَاطْمَئِن، وَافْتَرِشْ فَخِذَكَ الْيُسْرَى ثُم تَشَهدْ</b></p> </p> PART 2 <p id="posttextareadisplay"> <p class="ENGLISH">This is a samplasde textssss <b>فَإِذَا جَلَسْتَ فِي وَسَطِ الصلَاةِ فَاطْمَئِن، وَافْتَرِشْ فَخِذَكَ الْيُسْرَى ثُم تَشَهدْ</b></p> </p> Question PART 1 : If you see the code below, all paragraphs or <p> are class="ENGLISH". How to make it into a paragraph or <p> class="ENGLISH" to be class="ARAB", if the writing in a paragraph is Arabic? But if the writing is not Arabic, so the paragraph of class="ENGLISH" PART 1 <p id="posttextareadisplay"> <p class="ENGLISH">This is a samplasde textssss</p> <p class="ENGLISH"><b>فَإِذَا جَلَسْتَ فِي وَسَطِ الصلَاةِ فَاطْمَئِن، وَافْتَرِشْ فَخِذَكَ الْيُسْرَى ثُم تَشَهدْ</b></p> </p> ***** I WANT TO BE LIKE THIS ******* <p id="posttextareadisplay"> <p class="ENGLISH">This is a samplasde textssss</p> <p class="ARAB"><b>فَإِذَا جَلَسْتَ فِي وَسَطِ الصلَاةِ فَاطْمَئِن، وَافْتَرِشْ فَخِذَكَ الْيُسْرَى ثُم تَشَهدْ</b></p> </p> Question PART 2 : But if the Arabic joins with plain writing or regular fonts. So paragraph or <p> remain class="ENGLISH" Like this <p class="ENGLISH"> This is a sa <b> لْيُسْرَى ثُم تَشَهدْ</b></p> <p class="ENGLISH"><b> لْيُسْرَى ثُم تَشَهدْ</b> This is a sa</p> <p class="ENGLISH"> This is a sa <b> ا لْيُسْرَى ثُم تَشَهدْ</b> This is a sa</p> <p class="ENGLISH"><b> لْيُسْرَى ثُم تَشَهدْ</b> This is a sa <b> لْيُسْرَى ثُم تَشَهدْ</b></p> Note: I've tried this code, but it seems, this code encapsulates the entire contents of the textarea if (pattern.test(newText)) { str = newText.replace($format_search[i], $arab_format_replace[i]); } else { str = newText.replace($format_search[i], $format_replace[i]); } Quote Link to comment https://forums.phpfreaks.com/topic/304433-how-to-separate-arabic-with-alphabetical/ Share on other sites More sharing options...
requinix Posted July 27, 2017 Share Posted July 27, 2017 1. I suggest not having both the ENGLISH and ARAB classes and instead picking one (the primary language of the community) as the default and keeping the other. 2. Separate the language identification from the required markup. Don't class the but use a new for it. 3. HTML already has a thing for language: the lang attribute. English is "en", Arabic is "ar". فَإِذَا جَلَسْتَ فِي وَسَطِ الصلَاةِ فَاطْمَئِن، وَافْتَرِشْ فَخِذَكَ الْيُسْرَى ثُم تَشَهدْIf you accept that then I have a straightforward solution... probably, seems JSFiddle is having issues right now. Quote Link to comment https://forums.phpfreaks.com/topic/304433-how-to-separate-arabic-with-alphabetical/#findComment-1548953 Share on other sites More sharing options...
Natasha_Rana Posted July 27, 2017 Author Share Posted July 27, 2017 1. I suggest not having both the ENGLISH and ARAB classes and instead picking one (the primary language of the community) as the default and keeping the other. 2. Separate the language identification from the required markup. Don't class the <p> but use a new <span> for it. 3. HTML already has a thing for language: the lang attribute. English is "en", Arabic is "ar". <p><b><span lang="ar">فَإِذَا جَلَسْتَ فِي وَسَطِ الصلَاةِ فَاطْمَئِن، وَافْتَرِشْ فَخِذَكَ الْيُسْرَى ثُم تَشَهدْ</span></b></p>If you accept that then I have a straightforward solution... probably, seems JSFiddle is having issues right now. You better look at full in jsfiddle. Or in here http://liveweave.com/mtpkW6 Quote Link to comment https://forums.phpfreaks.com/topic/304433-how-to-separate-arabic-with-alphabetical/#findComment-1548954 Share on other sites More sharing options...
requinix Posted July 27, 2017 Share Posted July 27, 2017 That doesn't answer my question. But I just realized my solution is silly - you already have a regex that finds Arabic characters and puts a around them, so what I'm saying is to do str = str.replace(/([\u0600-\u06ED]+(?:\s+[\u0600-\u06ED]+)*)/g, '$1');and drop the specialized Arabic stuff to end up with. This is a sample textssssفَإِذَا جَلَسْتَ فِي وَسَطِ الصَّلَاةِ فَاطْمَئِنَّ، وَافْتَرِشْ فَخِذَكَ الْيُسْرَى ثُمَّ تَشَهَّدْ This is a sample textssss فَإِذَا جَلَسْتَ فِي وَسَطِ الصَّلَاةِ فَاطْمَئِنَّ، وَافْتَرِشْ فَخِذَكَ الْيُسْرَى ثُمَّ تَشَهَّدْAlternatively, assume all text is Arabic and change the regex above to deal with English instead (with lang=en). Quote Link to comment https://forums.phpfreaks.com/topic/304433-how-to-separate-arabic-with-alphabetical/#findComment-1548959 Share on other sites More sharing options...
Natasha_Rana Posted July 27, 2017 Author Share Posted July 27, 2017 (edited) That doesn't answer my question. But I just realized my solution is silly - you already have a regex that finds Arabic characters and puts a <b> around them, so what I'm saying is to do str = str.replace(/([\u0600-\u06ED]+(?:\s+[\u0600-\u06ED]+)*)/g, '<b lang="ar">$1</b>');and drop the specialized Arabic stuff to end up with. <p>This is a sample textssss</p><p><b lang="ar">فَإِذَا جَلَسْتَ فِي وَسَطِ الصَّلَاةِ فَاطْمَئِنَّ، وَافْتَرِشْ فَخِذَكَ الْيُسْرَى ثُمَّ تَشَهَّدْ</b></p> <p>This is a sample textssss <b lang="ar">فَإِذَا جَلَسْتَ فِي وَسَطِ الصَّلَاةِ فَاطْمَئِنَّ، وَافْتَرِشْ فَخِذَكَ الْيُسْرَى ثُمَّ تَشَهَّدْ</b></p>Alternatively, assume all text is Arabic and change the regex above to deal with English instead (with lang=en). It did not answer my problem. Because my problem is on replacing CLASS in <p> not lang. And lang="ar" is another problem Edited July 27, 2017 by Natasha_Rana Quote Link to comment https://forums.phpfreaks.com/topic/304433-how-to-separate-arabic-with-alphabetical/#findComment-1548966 Share on other sites More sharing options...
requinix Posted July 27, 2017 Share Posted July 27, 2017 You are ignoring my responses so now I will ignore yours. Quote Link to comment https://forums.phpfreaks.com/topic/304433-how-to-separate-arabic-with-alphabetical/#findComment-1548970 Share on other sites More sharing options...
Natasha_Rana Posted July 27, 2017 Author Share Posted July 27, 2017 (edited) You are ignoring my responses so now I will ignore yours. Because I do not understand what you mean? 1. I suggest not having both the ENGLISH and ARAB classes and instead picking one (the primary language of the community) as the default and keeping the other. 2. Separate the language identification from the required markup. Don't class the <p> but use a new <span> for it. 3. HTML already has a thing for language: the lang attribute. English is "en", Arabic is "ar". Edited July 27, 2017 by Natasha_Rana Quote Link to comment https://forums.phpfreaks.com/topic/304433-how-to-separate-arabic-with-alphabetical/#findComment-1548971 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.