I have used the answer from this question The best way to write Arabic in beamer by (Salim Bou) see here, but still there is a problem with the table of content, it should be aligned to right instead of being centered, see the picture below, any help please?
the code sample is:
% compile with xelatex
\documentclass[xcolor=table]{beamer}
\usetheme{Madrid}
\usepackage{polyglossia}
\setdefaultlanguage[calendar=gregorian,numerals=maghrib]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic]{Simplified Arabic}
\newfontfamily\arabicfontsf[Script=Arabic]{Simplified Arabic}
% for RTL liste
\makeatletter
\newcommand{\RTList}{\raggedleft\rightskip\@totalleftmargin}
\makeatother
% RTL frame title
\setbeamertemplate{frametitle}
{\vspace*{-1mm}
\nointerlineskip
\begin{beamercolorbox}[sep=0.3cm,ht=2.2em,wd=\paperwidth]{frametitle}
\vbox{}\vskip-2ex%
\strut\hskip1ex\insertframetitle\strut
\vskip-0.8ex%
\end{beamercolorbox}
}
% RTL triangle for itemize
\setbeamertemplate{itemize item}
{\scriptsize\raise1.25pt\hbox{\donotcoloroutermaths$\blacktriangleleft$}}
\newcommand\Fontvi{\fontsize{14}{10}\selectfont}
\begin{document}
\begin{frame}{المحتويات}
\tableofcontents
\end{frame}
\rightskip\rightmargin
\begin{frame}[allowframebreaks]
\frametitle{الشريحة الاولى}
\begin{block}{ادارة الحالات}
حالة جيدة
\end{block}
\end{frame}
\section{الدراسة المرجعية}
\subsection{مراحل الدراسة المرجعية}
\begin{frame}[allowframebreaks]
\frametitle{الشريحة الاولى}
\begin{block}{ادارة الحالات}
حالة جيدة
\end{block}
\end{frame}
\end{document}