我正在尝试获取外文数字的日期和年份数字。到目前为止,我已经能够获取带有 的月份名称\newcommand \date<lang>
。语言是梵语,文字是天城文。
这是我的妈妈:
\documentclass{beamer}
\mode<presentation>
{ \usetheme{metropolis} }
\usepackage{polyglossia}
\newfontfamily\devanagarifontsf[Script=Devanagari]{NotoSansDevanagari}
\newcommand{\devanagarinumeral}[1]{%
\devanagaridigits{\number\csname c@#1\endcsname}}
% renew all representation of counters
% \renewcommand{\thesection}{\devanagarinumeral{section}}
\renewcommand{\thepage}{\devanagarinumeral{page}}
% \renewcommand{\theenumi}{\devanagarinumeral{enumi}}
% this one is not fine
%\renewcommand{\day}{\devanagarinumeral{day}}
\setmainlanguage{sanskrit}
\setmainfont[Script=Devanagari]{NotoSansDevanagari}
% I will need to get independently day month and year
\usepackage{datetime2}
% This seems to do well for month names
\newcommand\datesanskrit{%
\def\today{\number\day~\ifcase\month\or
जनवरी\or फ़ेब्रवरी\or मार्च्\or एप्रील्\or मयि\or जून्\or
जुलै\or आगस्ट्\or सेप्टम्बर्\or आक्टोबर्\or नोवेम्बर्\or दिसेम्बर्\fi
\space\number\year
}%
}
\begin{document}
\begin{frame}{दिनङ्कः}
अ आ इ ई
\today % here I get "18 आक्टोबर् 2023"
% i want "१८ आक्टोबर् २०२३"
% later i will need to place the day number,
% the month, and the year alone independently
\end{frame}
\end{document}
答案1
\documentclass{beamer}
\mode<presentation>
{ \usetheme{metropolis} }
\usepackage{polyglossia}
\newfontfamily\devanagarifontsf[Script=Devanagari]{NotoSansDevanagari}
\setmainlanguage{sanskrit}
\setmainfont[Script=Devanagari]{NotoSansDevanagari}
\usepackage{datetime}
\newcommand\monthinsanskrit{%
\ifcase\month\or
जनवरी\or फ़ेब्रवरी\or मार्च्\or एप्रील्\or मयि\or जून्\or
जुलै\or आगस्ट्\or सेप्टम्बर्\or आक्टोबर्\or नोवेम्बर्\or दिसेम्बर्\fi
}%
\newcommand\daynameinsanskrit{%
\computedayofweek{\day}{\month}{\year}
\ifcase\dayofweek\or
रविवासरः\or सोमवासरः\or मङ्गलवासरः\or बुद्धवासरः\or
गुरुवासरः\or शुक्रवासरः\or शनिवासरः\fi
}%
\newcommand\dayindevadigits{\devanagaridigits{\the\day}}
\newcommand\yearindevadigits{\devanagaridigits{\the\year}}
\newcommand\dateinsanskrit{\daynameinsanskrit, \dayindevadigits %
\monthinsanskrit~\yearindevadigits}
\begin{document}
\begin{frame}{दिनङ्कः}
\dateinsanskrit
\end{frame}
\end{document}