%% This is file `quran-ur.sty', and it's completely relies on the quran package.
%% 
%% Copyright © 2019 by Seiied-Mohammad-Javad Razavian
%% <javadr@gmail.com>
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%% 
%% This work is “author-maintained” (as per LPPL maintenance status)
%% by Seiied-Mohammad-Javad Razavian..
%% The Current Maintainer of this work is Seiied-Mohammad-Javad Razavian.
%% 
%% This work consists of the files quran-ur.sty, 
%% qurantext-uri.translation.def, qurantext-urii.translation.def,
%% qurantext-uriii.translation.def, qurantext-uriv.translation.def, 
%% qurantext-urv.translation.def, qurantext-urvi.translation.def, 
%% qurantext-urvii.translation.def, qurantext-urviii.translation.def,  
%% quran-ur-doc.tex, quran-ur-doc.pdf, and quran.png. 
%%
%% To one having devoted his life to the Holy Quran
%%
%% Change Log
%% ver 0.1 ## May 3rd, 2019
%% initial commit
\NeedsTeXFormat{LaTeX2e}
\def\quranurdate{2019/05/03}
\def\quranurversion{ver 0.1}
\ProvidesPackage{quran-ur}[%
\quranurdate\space \quranurversion\space 
Urdu translations extension to the quran package.%
]
\RequirePackage{xstring}
\RequirePackage{biditools}
\RequirePackage{xkeyval}
\define@boolkeys{quran-ur.sty}[ur@]{ahmedali,jalandhry,jawadi,junagarhi,kanzuliman,maududi,najafi,qadri,all}[true]
\DeclareOptionX*{\PassOptionsToPackage{\CurrentOption}{quran}}
\DeclareOption*{\PackageWarning{quran-ur}{Unknown option ‘\CurrentOption’}}
\ProcessOptionsX\relax
\input{qurantext-urii.translation.def}%
\ifur@all
    \ExecuteOptionsX{ahmedali,jalandhry,jawadi,junagarhi,kanzuliman,maududi,najafi,qadri}
\else
    \ExecuteOptionsX{jalandhry}
\fi
\RequirePackage{quran}
%
\ifur@maududi%
    \PackageInfo{quran-ur}{Abul A'ala Maududi's translation is chosen.}%
\fi%
\ifur@kanzuliman%
    \PackageInfo{quran-ur}{Ahmed Raza Khan's translation is chosen.}%
\fi%
\ifur@ahmedali%
    \PackageInfo{quran-ur}{Ahmed Ali's translation is chosen.}%
\fi%
\ifur@jalandhry%
    \PackageInfo{quran-ur}{Fateh Muhammad Jalandhry's translation is chosen.}%
\fi%
\ifur@qadri%
    \PackageInfo{quran-ur}{Tahir ul Qadri's translation is chosen.}%
\fi%
\ifur@jawadi%
    \PackageInfo{quran-ur}{Syed Zeeshan Haider Jawadi's translation is chosen.}%
\fi%
\ifur@junagarhi%
    \PackageInfo{quran-ur}{Muhammad Junagarhi's translation is chosen.}%
\fi%
\ifur@najafi%
    \PackageInfo{quran-ur}{Muhammad Hussain Najafi's translation is chosen.}%
\fi%
\newcount\trans@ur
\trans@ur=\@ne
\define@choicekey*+{quran-ur}{trans}[\val\nr]{ahmedali,jalandhry,jawadi,junagarhi,kanzuliman,maududi,najafi,qadri}{%
    \ifcase\nr\relax
        \global\trans@ur=\z@\relax
    \or
        \global\trans@ur=\@ne\relax
    \or
        \global\trans@ur=\tw@\relax
    \or
        \global\trans@ur=\thr@@\relax
    \or
        \global\trans@ur=4\relax
    \or
        \global\trans@ur=5\relax
    \or
        \global\trans@ur=6\relax
    \or
        \global\trans@ur=7\relax
 \fi}{%
    \PackageWarning{quran-ur}{\string \urSetTrans' paramenter should be one of  `maududi', `kanzuliman', `ahmedali', `jalandhry', `qadri', `jawadi', `junagarhi', or `najafi'. The package sets to `jalandhry' by default.}{}%
    \global\trans@ur=\@ne\relax
}%
\newcommand*{\urGetTrans}{%
    \ifcase\trans@ur
        ahmedali%
    \or
        jalandhry%
    \or
        jawadi%
    \or
        junagarhi%
    \or
        kanzuliman%
    \or
        maududi%
    \or
        najafi%
    \or
        qadri%                                
    \fi%
}
\newcommand{\urSetTrans}[1]{%
\IfInteger{#1}%
{%Yes
\count255=#1%
\advance\count255 by -1\relax%
\trans@ur=\count255}%
{%NO
\setkeys{quran-ur}{trans=#1}}%
%
\makeatother
\let\bidi@newrobustcmd\bidi@renewrobustcmd
\makeatletter
\ifcase\trans@ur%0
    \ifur@ahmedali%
        \ifx\basmalahur\relax\else%
            \def\basmalahur{شروع الله کا نام لے کر جو بڑا مہربان نہایت رحم والا ہے \qt@par}%
        \fi%
        \bidi@renewrobustcmd\ToggleBasmalahur{%
            \ifx\basmalahur\relax%
                \def\basmalahur{شروع الله کا نام لے کر جو بڑا مہربان نہایت رحم والا ہے \qt@par}%
            \else%
                \let\basmalahur\relax%
            \fi%
        }%        
        \input{qurantext-uri.translation.def}%
    \else%
        \PackageError{quran-ur}{Ahmed Ali's translation has not been loaded}{}%
    \fi%
\or%1
    \ifur@jalandhry
        \ifx\basmalahur\relax\else%
            \def\basmalahur{شروع الله کا نام لے کر جو بڑا مہربان نہایت رحم والا ہے \qt@par}%
        \fi
        \bidi@renewrobustcmd\ToggleBasmalahur{%
            \ifx\basmalahur\relax%
                \def\basmalahur{شروع الله کا نام لے کر جو بڑا مہربان نہایت رحم والا ہے \qt@par}%
            \else%
                \let\basmalahur\relax%
            \fi%
        }%      
        \input{qurantext-urii.translation.def}%
    \else%
        \PackageError{quran-ur}{Fateh Muhammad Jalandhry's translation has not been loaded}{}%
    \fi
\or%2
    \ifur@jawadi
        \ifx\basmalahur\relax\else%
            \def\basmalahur{عظیم اور دائمی رحمتوں والے خدا کے نام سے \qt@par}%
        \fi    
        \bidi@renewrobustcmd\ToggleBasmalahur{%
            \ifx\basmalahur\relax%
                \def\basmalahur{عظیم اور دائمی رحمتوں والے خدا کے نام سے \qt@par}%
            \else%
                \let\basmalahur\relax%
            \fi%
        }%          
        \input{qurantext-uriii.translation.def}%
    \else%
        \PackageError{quran-ur}{Syed Zeeshan Haider Jawadi's translation has not been loaded}{}%
    \fi
\or%3
    \ifur@junagarhi
        \ifx\basmalahur\relax\else%
            \def\basmalahur{شروع کرتا ہوں اللہ تعالیٰ کے نام سے جو بڑا مہربان نہایت رحم واﻻ ہے \qt@par}%
        \fi            
        \bidi@renewrobustcmd\ToggleBasmalahur{%
            \ifx\basmalahur\relax%
                \def\basmalahur{شروع کرتا ہوں اللہ تعالیٰ کے نام سے جو بڑا مہربان نہایت رحم واﻻ ہے \qt@par}%
            \else%
                \let\basmalahur\relax%
            \fi%
        }%         
        \input{qurantext-uriv.translation.def}%
    \else%
        \PackageError{quran-ur}{Muhammad Junagarhi's translation has not been loaded}{}%
    \fi
\or%4
    \ifur@kanzuliman
        \ifx\basmalahur\relax\else%
            \def\basmalahur{اللہ کے نام سے شروع جو بہت مہربان رحمت والا \qt@par}%
        \fi            
        \bidi@renewrobustcmd\ToggleBasmalahur{%
            \ifx\basmalahur\relax%
                \def\basmalahur{اللہ کے نام سے شروع جو بہت مہربان رحمت والا \qt@par}%
            \else%
                \let\basmalahur\relax%
            \fi%
        }%         
        \input{qurantext-urv.translation.def}%
    \else%
        \PackageError{quran-ur}{Ahmed Raza Khan's translation has not been loaded}{}%
    \fi
\or%5
    \ifur@maududi
        \ifx\basmalahur\relax\else%
            \def\basmalahur{اللہ کے نام سے جو رحمان و رحیم ہے \qt@par}%
        \fi            
        \bidi@renewrobustcmd\ToggleBasmalahur{%
            \ifx\basmalahur\relax%
                \def\basmalahur{اللہ کے نام سے جو رحمان و رحیم ہے \qt@par}%
            \else%
                \let\basmalahur\relax%
            \fi%
        }%         
        \input{qurantext-urvi.translation.def}%
    \else%
        \PackageError{quran-ur}{Abul A'ala Maududi's translation has not been loaded}{}%
    \fi
\or%6
    \ifur@najafi
        \ifx\basmalahur\relax\else%
            \def\basmalahur{(شروع کرتا ہوں) اللہ کے نام سے جو بڑا مہربان نہایت رحم والا ہے۔ \qt@par}%
        \fi            
        \bidi@renewrobustcmd\ToggleBasmalahur{%
            \ifx\basmalahur\relax%
                \def\basmalahur{(شروع کرتا ہوں) اللہ کے نام سے جو بڑا مہربان نہایت رحم والا ہے۔ \qt@par}%
            \else%
                \let\basmalahur\relax%
            \fi%
        }%         
        \input{qurantext-urvii.translation.def}%
    \else%
        \PackageError{quran-ur}{Muhammad Hussain Najafi's translation has not been loaded}{}%
    \fi
\or%7
    \ifur@qadri
        \ifx\basmalahur\relax\else%
            \def\basmalahur{اللہ کے نام سےشروع جو نہایت مہربان ہمیشہ رحم فرمانےوالا ہے \qt@par}%
        \fi            
        \bidi@renewrobustcmd\ToggleBasmalahur{%
            \ifx\basmalahur\relax%
                \def\basmalahur{اللہ کے نام سےشروع جو نہایت مہربان ہمیشہ رحم فرمانےوالا ہے \qt@par}%
            \else%
                \let\basmalahur\relax%
            \fi%
        }%         
        \input{qurantext-urviii.translation.def}%
    \else%
        \PackageError{quran-ur}{Tahir ul Qadri's translation has not been loaded}{}%
    \fi                
\else%
    \PackageError{quran-ur}{\string \urSetTrans{} paramenter should be between 1 to 8}{}%
\fi
}%
\bidi@newrobustcmd\ToggleBasmalahur{%
    \ifx\basmalahur\relax%
        \ifcase\trans@ur% ahmedali
            \def\basmalahur{شروع الله کا نام لے کر جو بڑا مہربان نہایت رحم والا ہے \qt@par}%
        \or% jalandhry
            \def\basmalahur{شروع الله کا نام لے کر جو بڑا مہربان نہایت رحم والا ہے \qt@par}%
        \or% jawadi
            \def\basmalahur{عظیم اور دائمی رحمتوں والے خدا کے نام سے \qt@par}%
        \or% junagarhi
            \def\basmalahur{شروع کرتا ہوں اللہ تعالیٰ کے نام سے جو بڑا مہربان نہایت رحم واﻻ ہے \qt@par}%
        \or% kanzuliman    
            \def\basmalahur{اللہ کے نام سے شروع جو بہت مہربان رحمت والا \qt@par}%
        \or% maududi
            \def\basmalahur{اللہ کے نام سے جو رحمان و رحیم ہے \qt@par}%
        \or% najafi
            \def\basmalahur{(شروع کرتا ہوں) اللہ کے نام سے جو بڑا مہربان نہایت رحم والا ہے۔ \qt@par}%
        \or% qadri
            \def\basmalahur{اللہ کے نام سےشروع جو نہایت مہربان ہمیشہ رحم فرمانےوالا ہے \qt@par}%
        \fi%
    \else%
        \let\basmalahur\relax%
    \fi%
}%
\let\qt@doqt@orig\qt@doqt
\let\ToggleBasmalah@orig\ToggleBasmalah
%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\basmalahur{شروع الله کا نام لے کر جو بڑا مہربان نہایت رحم والا ہے \qt@par}%
%\bidi@newrobustcmd\ToggleBasmalahur{%
%  \ifx\basmalahde\relax%
%    \def\basmalahur{شروع الله کا نام لے کر جو بڑا مہربان نہایت رحم والا ہے \qt@par}%
%  \else%
%    \let\basmalahde\relax%
%  \fi%
%}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\bidi@newrobustcmd\qt@dour{%
    \addtocounter{qt@count}{1}%
    \loop%
        \csname qurantrans@ur@\roman{qt@count}\endcsname%
        \ifnum\value{qt@count}<\qt@max\relax%
        { }% an extra space between verses
        \qt@par%
        \addtocounter{qt@count}{1}%
    \repeat%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\bidi@newrobustcmd\qurantextur{%
    \@ifstar\@@qurantextur\@qurantextur%
}%
\bidi@newrobustcmd\@@qurantextur[1][\qt@default]{%
    \let\qt@doqt\qt@dour%
    \@@qurantext[#1]%
    \let\qt@doqt\qt@doqt@orig%    
}%
\bidi@newrobustcmd\@qurantextur[1][\qt@default]{%
    \let\qt@doqt\qt@dour%
    \@qurantext[#1]%
    \let\qt@doqt\qt@doqt@orig%    
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\bidi@newrobustcmd\quransurahur{%
    \@ifstar\@@quransurahur\@quransurahur%
}%
\bidi@newrobustcmd\@@quransurahur[1][\qt@surah@default]{%
    \let\qt@doqt\qt@dour%
    \@@quransurah[#1]%
    \let\qt@doqt\qt@doqt@orig%    
}%
\bidi@newrobustcmd\@quransurahur[1][\qt@surah@default]{%
    \let\qt@doqt\qt@dour%
    \lowercase{\def\qt@arglc{#1}}%
    \@quransurah[\qt@arglc]%
    \let\qt@doqt\qt@doqt@orig%    
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\bidi@newrobustcmd\quranayahur{%
    \@ifstar\@@quranayahur\@quranayahur%
}%
\def\@@quranayahur[#1][#2]{%
    \let\qt@doqt\qt@dour%
    \let\ToggleBasmalah\ToggleBasmalahur%
    \@@quranayah[#1][#2]%
    \let\qt@doqt\qt@doqt@orig%    
    \let\ToggleBasmalah\ToggleBasmalah@orig%
}%
\def\@quranayahur[#1][#2]{%
    \lowercase{\def\qt@arglc{#1}}%
    \let\qt@doqt\qt@dour%
    \let\ToggleBasmalah\ToggleBasmalahur%    
    \@quranayah[\qt@arglc][#2]%
    \let\qt@doqt\qt@doqt@orig%    
    \let\ToggleBasmalah\ToggleBasmalah@orig%    
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\bidi@newrobustcmd\quranjuzur{%
    \@ifstar\@@quranjuzur\@quranjuzur%
}%
\def\@@quranjuzur[#1]{%
    \let\qt@doqt\qt@dour%
    \@@quranjuz[#1]%
    \let\qt@doqt\qt@doqt@orig%    
}%
\def\@quranjuzur[#1]{%
    \let\qt@doqt\qt@dour%
    \@quranjuz[#1]%
    \let\qt@doqt\qt@doqt@orig%    
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\bidi@newrobustcmd\quranpageur{%
    \@ifstar\@@quranpageur\@quranpageur%
}%
\def\@@quranpageur[#1]{%
    \let\qt@doqt\qt@dour%
    \@@quranpage[#1]%
    \let\qt@doqt\qt@doqt@orig%    
}%
\def\@quranpageur[#1]{%
    \let\qt@doqt\qt@dour%
    \@quranpage[#1]%
    \let\qt@doqt\qt@doqt@orig%    
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\bidi@newrobustcmd\quranquarterur{%
  \@ifstar\@@quranquarterur\@quranquarterur%
}%
\def\@@quranquarterur[#1]{%
    \let\qt@doqt\qt@dour%
    \@@quranquarter[#1]%
    \let\qt@doqt\qt@doqt@orig%    
}%
\def\@quranquarterur[#1]{%
    \let\qt@doqt\qt@dour%
    \@quranquarter[#1]%
    \let\qt@doqt\qt@doqt@orig%    
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\bidi@newrobustcmd\quranrukuur{%
    \@ifstar\@@quranrukuur\@quranrukuur%
}%
\def\@@quranrukuur[#1]{%
    \let\qt@doqt\qt@dour%
    \@@quranruku[#1]%
    \let\qt@doqt\qt@doqt@orig%    
}%
\def\@quranrukulde[#1]{%
    \let\qt@doqt\qt@dode%
    \@quranruku[#1]%
    \let\qt@doqt\qt@doqt@orig%    
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\bidi@newrobustcmd\quranhizbur{%
    \@ifstar\@@quranhizbur\@quranhizbur%
}%
\def\@@quranhizbur[#1]{%
    \let\qt@doqt\qt@dour%
    \@@quranhizb[#1]%
    \let\qt@doqt\qt@doqt@orig%    
}%
\def\@quranhizbur[#1]{%
    \let\qt@doqt\qt@dour%
    \@quranhizb[#1]%
    \let\qt@doqt\qt@doqt@orig%    
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\bidi@newrobustcmd\quranmanzilur{%
    \@ifstar\@@quranmanzilur\@quranmanzilur%
}
\def\@@quranmanzilur[#1]{%
    \let\qt@doqt\qt@dour%
    \@@quranmanzil[#1]%
    \let\qt@doqt\qt@doqt@orig%    
}%
\def\@quranmanzilur[#1]{%
    \let\qt@doqt\qt@dour%
    \@quranmanzil[#1]%
    \let\qt@doqt\qt@doqt@orig%    
}%
%\urSetTrans{jalandhry}%default translation
%%%%%%%%%%%%%%%%%%%%%%%%%%
%% End of file `quran-ur.sty'.
