Jump to content

How to separate Arabic with alphabetical?


Natasha_Rana
 Share

Recommended Posts

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]);
}
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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).
Link to comment
Share on other sites

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 by Natasha_Rana
Link to comment
Share on other sites

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 by Natasha_Rana
Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.