Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow query param to strip Bismillah from first ayahs #17

Open
meezaan opened this issue Jan 11, 2019 · 10 comments
Open

Allow query param to strip Bismillah from first ayahs #17

meezaan opened this issue Jan 11, 2019 · 10 comments
Assignees

Comments

@meezaan
Copy link
Member

meezaan commented Jan 11, 2019

No description provided.

@meezaan meezaan self-assigned this Jan 11, 2019
@RabeeAbuBaker
Copy link

RabeeAbuBaker commented May 19, 2020

I had to do it manually:

if (this.surahNumber !== 1) {
// Remvoing basmala
this.ayahs[0].text = this.ayahs[0].text.substring(38);
}

@vipafattal
Copy link

vipafattal commented May 19, 2020

@Rabubaker
This way of removing Baslmalih has a lot of drawbacks, this will remove more text in Surah Tawba since no Baslmalih in it, and in some cases, the Baslmalih has Arabic Shadiha ( ّ ) such as Surah AlQader, in this case, the length of Baslmalih is no longer 38.

My solution to this is to get the range of Baslmalih by getting the first index of "ٱلرَّحِيمِ" then replacing this range with an empty string:

(This code is in Kotlin, but I think you can find something similar for what are you programming in)

const val Fatiha = "Al-Faatiha"
const val Tawba = "At-Tawba"
    
fun getEndIndexOfBasmalih(): Int {
        //Works only for quran-uthmani
        val string = "ٱلرَّحِيمِ"
        return ayaText.indexOf(string, 0) + string.length
    }

fun getTextWithoutBasmalih(numberInSurah :Int): String {
      return   if (numberInSurah == 1 
            &&  surah!!.englishName != MushafConstants.Fatiha
            &&  surah!!.englishName != MushafConstants.Tawba)
            ayaText.substring(getEndIndexOfBasmalih(), ayaText.length)
        else ayaText
    }

@RabeeAbuBaker
Copy link

@Rabubaker
This way of removing Baslmalih has a lot of drawbacks, this will remove more text in Surah Tawba since no Baslmalih in it, and in some cases, the Baslmalih has Arabic Shadiha ( ّ ) such as Surah AlQader, in this case, the length of Baslmalih is no longer 38.

My solution to this is to get the range of Baslmalih by getting first index of "ٱلرَّحِيمِ" then replacing this range with an empty string:

(This code is in Kotlin, but I think you can find something similar for what are you programming in)

const val Fatiha = "Al-Faatiha"
const val Tawba = "At-Tawba"
    
fun getEndIndexOfBasmalih(): Int {
        val string = "ٱلرَّحِيمِ"
        return ayaText.indexOf(string, 0) + string.length
    }

fun getTextWithoutBasmalih(numberInSurah :Int): String {
      return   if (numberInSurah == 1 && surah.englishName != Fatiha)
            ayaText.replaceRange(0, getEndIndexOfBasmalih(), "")
        else ayaText
    }

Thanks a lot for pointing out to this.. it was indeed helpful.

I am programming in ES6/Angular. I will certainly do something similar. JazakAllah Kahir..

@vipafattal
Copy link

Most Welcome

@meezaan
Copy link
Member Author

meezaan commented May 20, 2020

@vipafattal @Rabubaker this will only work with quran-uthmani - not with quran-simple - incase anyone is using that.

@vipafattal
Copy link

@vipafattal @Rabubaker this will only work with quran-uthmani - not with quran-simple - incase anyone is using that.

Yes I'm using it with quran-uthmani if someone is not using generic Quran version, they can replace

val string = "ٱلرَّحِيمِ"

with same version of end Basmalih in quran-simple, otherwise, I would suggest splitting first Aya by whitespace I think this will work fine in all quran version:

fun getEndIndexOfBasmalih(): Int {
    val split = ayaText.split(' ')
    return ayaText.indexOf(split[3], 0) +  split[3].length
}

@meezaan
Copy link
Member Author

meezaan commented May 20, 2020

Thanks @vipafattal I will try and prioritise this to deal with it on the API side.

@RabeeAbuBaker
Copy link

Any update on this? @meezaan

@meezaan
Copy link
Member Author

meezaan commented Aug 27, 2020

Al Salaamu Alaykum @RabeeAbuBaker. It's number 5 on the backlog - https://github.com/orgs/islamic-network/projects/5 - so not yet, I'm afraid. But soon, God willing!

@ghazalitajuddin
Copy link

I use .replace() method. Those unicode is part of Bismillah. Hope helps.

strippedContent: function(string) { return string.replace("\u0628\u0650\u0633\u0652\u0645\u0650 \u0627\u0644\u0644\u0651\u064e\u0647\u0650 \u0627\u0644\u0631\u0651\u064e\u062d\u0652\u0645\u064e\u0670\u0646\u0650 \u0627\u0644\u0631\u0651\u064e\u062d\u0650\u064a\u0645\u0650", ""); },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants