npm promulgates marsupials
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    the-amazing-quran-translationspublic

    The Amazing Quran | Translations

    بسم الله الرحمن الرحيم

    This node module allows you to easily retrieve surah or ayah from quran in several languages

    No database is required, you just need to have node installed !

    How to use ?

    Installation

    $> npm install the-amazing-quran-translations

    Get Available Languages

    getAvailableLanguages()

    This function return an array of string containing the available languages

    Get Surah

    This function allows you to retrieve a surah from the Quran

    getSurah(surahNumber, translations)
     
    // translations is optional
    // translation can be a String, an Object, or an Array of Object
    // Object need to have this structure
    // {
    //   languageName: String
    //  authorName: String  [optional]
    // }
    Return value

    This function return a surah object if the surah number is correct. If not, it return false. By default, it return the arabic version.

    // surah object
    {
      surahNumber: String,
      surahName: String,
      translatedSurahNames: Object,
      ayahs: Array[{ ayahNumber: String, ayahContent: String, translationName: string }]
    }
    Examples
    var quranManager = require('the-amazing-quran-translations')();
     
    // Get surah al fatiha in arabic
    quranManager.getSurah(1);
     
    // Get surah al fatiha in english
    quranManager.getSurah(1, 'english');
     
    // Get surah al fatiha in english french and german
    quranManager.getSurah(1, 'english,french,german');
     
    // Get surah al fatiha in english translated by Yusuf Ali
    var foo = quranManager.getSurah(112, [{ languageName: 'french'}, {languageName: 'english', authorName: 'Yusuf_Ali'}, {languageName: 'chinese'}]);
     
    console.log(foo);
    // Will display :
    {
        surahNumber: '112',
       surahName: 'الإخلاص',
       translatedSurahNames:
        {
            french: 'Le monothéisme pur (Al-Ihlas)',
            english: 'The Unity',
            chinese: '忠 誠'
        },
       ayahs:
           [ { ayahNumber: '1',
               ayahContent: 'قُلْ هُوَ اللَّهُ أَحَدٌ',
               french: 'Dis : "Il est Allah, Unique.',
               english: 'Say: He is Allah, the One and Only;',
               chinese: '你說:他是真主,是獨一的主;' },
             { ayahNumber: '2',
               ayahContent: 'اللَّهُ الصَّمَدُ',
               french: 'Allah, Le Seul à être imploré pour ce que nous désirons.',
               english: 'Allah, the Eternal, Absolute;',
               chinese: '真主是萬物所仰賴的;' },
             { ayahNumber: '3',
               ayahContent: 'لَمْ يَلِدْ وَلَمْ يُولَدْ',
               french: 'Il n´a jamais engendré, n´a pas été engendré non plus.',
               english: 'He begetteth not, nor is He begotten;',
               chinese: '他沒有生產,也沒有被生產;' },
             { ayahNumber: '4',
               ayahContent: 'وَلَمْ يَكُنْ لَهُ كُفُوًا أَحَدٌ',
               french: 'Et nul n´est égal à Lui".',
               english: 'And there is none like unto Him.',
               chinese: '沒有任何物可以做他的匹敵。' }
           ]
    }

    Get Ayah

    This function allows you to retrieve an ayah from the Quran

    getAyah(surahNumber, ayahNumber, translations)
     
    // translations is optional
    // translation can be a String, an Object, or an Array of Object
    // Object need to have this structure
    // {
    //   languageName: String
    //  authorName: String  [optional]
    // }
    Return value

    This function return an ayah object if the surah and ayah number are correct. If not, it return false. By default, it return the arabic version.

    // ayah object
    {
      ayahNumber: String,
      ayahContent: String,
      translationName: String,
      surah: Object { surahNumber: String, surahName: String, translatedSurahNames: Object }
    }
    Examples
    var quranManager = require('the-amazing-quran-translations')();
     
    // Get ayah number 2 from surah al fatiha in german
    quranManager.getAyah(1, 2);
     
    // Get ayah number 43 from surah 7 in arabic
    var bar = quranManager.getAyah(7, 43, 'french');
     
    console.log(bar);
    // Will display
    { ayahNumber: '43',
      ayahContent: 'وَنَزَعْنَا مَا فِي صُدُورِهِمْ مِنْ غِلٍّ تَجْرِي مِنْ تَحْتِهِمُ الْأَنْهَارُ ۖ وَقَالُوا الْحَمْدُ لِلَّهِ الَّذِي هَدَانَا لِهَٰذَا وَمَا كُنَّا لِنَهْتَدِيَ لَوْلَا أَنْ هَدَانَا اللَّهُ ۖ لَقَدْ جَاءَتْ رُسُلُ رَبِّنَا بِالْحَقِّ ۖ وَنُودُوا أَنْ تِلْكُمُ الْجَنَّةُ أُورِثْتُمُوهَا بِمَا كُنْتُمْ تَعْمَلُونَ',
      french: 'Et Nous enlèverons toute la rancune de leurs poitrines, sous eux couleront les ruisseaux, et ils diront : "Louange à Allah qui nous a guidés à ceci. Nous n´aurions pas été guidés, si Allah ne nous avait pas guidés. Les messagers de notre Seigneur sont venus avec la vérité." Et on leur proclamera : "Voilà le Paradis qui vous a été donné en héritage pour ce que vous faisiez".',
      surah:
       {
         surahNumber: '7',
         surahName: 'الأعراف',
         translatedSurahNames: { french: 'Al-Araf'
       }
    }
     

    Source code

    The source code is in the src directory.

    Since the module is develop in ES6, a simple gulp task using Babel.js convert it in ES5.

    Translations

    All translations are in the translations directory.

    The different translations of the Quran are sotred in JSON files. All JSON translations are based on the XML files download from http://qurandatabase.org

    Next features

    Here is a none exhaustive list of features that can be implemented

    • add test cases
    • get surah by name
    • multiple translation of same language in one surah/ayah
    • add the mekkah/medina surah information
    • search function
    • get the surah length

    Permissions

    This module is open source. You can use, share, copy, modify and distribute this app as you want as long as you don't have a bad purpose

    Issues

    If you find any issues on this project, please report on the issue section of github or send a mail to captainyouz@gmail.com

    install

    npm i the-amazing-quran-translations

    Downloadslast 7 days

    1

    version

    1.0.0

    license

    ISC

    repository

    github.com

    last publish

    collaborators

    • avatar