%% This is file `quran-ur.sty', and it's completely relies on the quran package.
%%
%% Copyright © 2019-2020 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
%%
\NeedsTeXFormat{LaTeX2e}
\def\quranurdate{2021/02/02}
\def\quranurversion{0.21}
\ProvidesPackage{quran-ur}[%
\quranurdate\space v\quranurversion\space^^J
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
\ifur@all
    \ExecuteOptionsX{ahmedali,jalandhry,jawadi,junagarhi,kanzuliman,maududi,najafi,qadri}
\else
    \ExecuteOptionsX{jalandhry}
\fi
\RequirePackage{quran}
\ifqt@wordwise%
    \let\qt@newcmd\newcommand
\else%
    \let\qt@newcmd\bidi@newrobustcmd
\fi%
\input{qurantext-urii.translation.def}%
%
\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
\ifqt@wordwise%
    \makeatother\let\qt@newcmd\renewcommand\makeatletter%
\else%
    \makeatother\let\qt@newcmd\bidi@renewrobustcmd\makeatletter%
\fi%
\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
%%%%%%%%%%%%%%%%%%%%%%%%%%
\bidi@apptocmd{\ToggleBasmalah}{\ToggleBasmalahur}{}{}
\let\ToggleBasmalah@orig\ToggleBasmalah
\def\basmalahur{شروع الله کا نام لے کر جو بڑا مہربان نہایت رحم والا ہے \qt@par}%
\def\Basmalahur{%
        \begingroup%
        \let\par\relax%
        \def\qt@no##1{\relax}%
        \quranayahur[1][1][1]%
        \endgroup%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareDocumentCommand\qt@dour{ o o }{%
    \addtocounter{qt@count}{1}%
    \def\@qtexp{}%
    \loop%
        \global\xdef\@qtexp{\@qtexp\csname qurantrans@ur@\roman{qt@count}\endcsname\ifnum\value{qt@count}=\qt@max\else\space\fi\qt@par}%
        \ifnum\value{qt@count}<\qt@max\relax%
        \addtocounter{qt@count}{1}%
    \repeat%
    \IfNoValueTF{#1}%
    {\@qtexp}%true
    {\qt@WordCount=0\relax\c@qt@start=\numexpr#1-1\relax%
    \readlist*\qt@words{\@qtexp}%
        \IfNoValueTF{#2}%
        {\c@qt@end=\numexpr\qt@wordslen+1\relax}{\c@qt@end=\numexpr#2+1\relax}%
        \foreachitem\qt@word\in\qt@words{%
            \ifnum\qt@wordcnt>\c@qt@start\ifnum\qt@wordcnt<\c@qt@end\qt@word\ifnum\qt@wordcnt=\numexpr\c@qt@end-1\relax\else\xspace\fi\fi\fi%
        }%
        \qt@showitems{\ifdefined\arabicfont\arabicfont\fi\showitems\qt@words}%
    }%false
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareDocumentCommand{\qurantextur}{ s O{\qt@default} o t{+} }{%
    \IfBooleanTF{#4}{\def\qt@showitems##1{\footnote{##1}}}{\def\qt@showitems##1{\relax}}%
    \let\qt@doqt\qt@dour%
    \IfBooleanTF{#1}%
    {\IfBooleanTF{#4}{\qurantext*[#2][#3]+}{\qurantext*[#2][#3]}}%
    {\IfBooleanTF{#4}{\qurantext[#2][#3]+}{\qurantext[#2][#3]}}%
    \let\qt@doqt\qt@doqt@orig%
    \def\qt@showitems##1{\relax}%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareDocumentCommand\quransurahur{ s O{\qt@surah@default} }{%
    \let\qt@doqt\qt@dour%
    \IfBooleanTF{#1}%
    {\quransurah*[#2]}%
    {\quransurah[#2]}%
    \let\qt@doqt\qt@doqt@orig%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareDocumentCommand{\quranayahur}{ s o o o t{+} }{%
    \let\qt@doqt\qt@dour%
    \let\ToggleBasmalah\ToggleBasmalahur%
    \IfBooleanTF{#1}%
    {\IfBooleanTF{#5}{\quranayah*[#2][#3][#4]+}{\quranayah*[#2][#3][#4]}}%
    {\IfBooleanTF{#5}{\quranayah[#2][#3][#4]+}{\quranayah[#2][#3][#4]}}%
    \let\qt@doqt\qt@doqt@orig%
    \let\ToggleBasmalah\ToggleBasmalah@orig%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareDocumentCommand{\quranjuzur}{ s o }{%
    \let\qt@doqt\qt@dour%
    \IfBooleanTF{#1}%
    {\quranjuz*[#2]}%
    {\quranjuz[#2]}%
    \let\qt@doqt\qt@doqt@orig%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareDocumentCommand{\quranpageur}{ s o }{%
    \let\qt@doqt\qt@dour%
    \IfBooleanTF{#1}%
    {\quranpage*[#2]}%
    {\quranpage[#2]}%
    \let\qt@doqt\qt@doqt@orig%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareDocumentCommand{\quranquarterur}{ s o }{%
    \let\qt@doqt\qt@dour%
    \IfBooleanTF{#1}%
    {\quranquarter*[#2]}%
    {\quranquarter[#2]}%
    \let\qt@doqt\qt@doqt@orig%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareDocumentCommand{\quranrukuur}{ s o }{%
    \let\qt@doqt\qt@dour%
    \IfBooleanTF{#1}%
    {\quranruku*[#2]}%
    {\quranruku[#2]}%
    \let\qt@doqt\qt@doqt@orig%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareDocumentCommand{\quranhizbur}{ s o }{%
    \let\qt@doqt\qt@dour%
    \IfBooleanTF{#1}%
    {\quranhizb*[#2]}%
    {\quranhizb[#2]}%
    \let\qt@doqt\qt@doqt@orig%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareDocumentCommand{\quranmanzilur}{ s o }{%
    \let\qt@doqt\qt@dour%
    \IfBooleanTF{#1}%
    {\quranmanzil*[#2]}%
    {\quranmanzil[#2]}%
    \let\qt@doqt\qt@doqt@orig%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%
%% End of file `quran-ur.sty'.
