[Tex/LaTex] \today and language (babel, xepersian)

babelfontslanguagesxepersian

I'm using xepersian for my article but in one page I need to add Gregorian calendar date. so I add:

\usepackage[british]{babel}

and then where I want the date:

\selectlanguage{british}
{\large \today}

butthen where ever I use today it writes Gregorian instead of persian (still in persian but uses Gregorian calender) and figure caption texts (like Fig.) is in english instead of persian.

EDIT:

\documentclass[14pt,a4paper]{article}

%\usepackage[british]{babel}
\usepackage{enumerate}
\usepackage{xepersian}
\settextfont{XB Niloofar}

\begin{document}
\today
\end{document}

Like this the printed date is from persian calendar like this (reads 16th of khordad 1393):

enter image description here

but when I uncomment that line it will be english language in persian like this(reads 6th of june 2014):

enter image description here

Best Answer

Two things up front:

  1. As XePersian is relying on the XeTeX engine, I would recommend using polyglossia instead of babel.
  2. The article document class cannot use the 14pt option; for more information, take a look at this answer.

The Problem in your case is that XePersian clearly changes all western numerals (123) into genuine Arabic numerals (١٢٣), even though the XB Niloofar font contains both. Therefore, you need to tell XeTeX to use a different font than XePersian uses with \settextfont. If you do not specify a different font, XePersian will be used for typesetting, which will of course substitute the numerals.

First, of course, you need to tell XeTeX there is another language besides Farsi. You should use polyglossia to set this up: \setotherlanguage[]{english}. Then you must tell polyglossia to use a different font for all English text with \newfontfamily\englishfont{XB Niloofar}. This can of course be the exact same typeface as your XePersian \settextfont, but this time, it will not go through XePersian and thusly use the correct number forms. In the document, use \textenglish{} or \begin{english} to switch to an English environment.

Using the above suggestions will yield the following MWE:

\documentclass[12pt,a4paper]{article}

\usepackage{polyglossia}

%\setdefaultlanguage[]{farsi}
\setotherlanguage[]{english}
\newfontfamily\englishfont{XB Niloofar}

\usepackage{enumerate}
\usepackage{xepersian}

\settextfont{XB Niloofar}


\begin{document}
\today

\textenglish{\today}
\end{document}

which gives this output:

XePersian output


On a side note, setting \setdefaultlanguage[]{farsi}, which would be normal practice with polyglossia, does not work, because it clashes with XePersian, therefore it is commented out here but you are welcome to delete it.