month form \currentdate in Roman numerals

Dear list, I would like to get the current month in Roman numerals (just now, it would be XII for December). The best I get is: \currentdate[\cldcontext{converters['R'] (tonumber(os.date("\letterpercent m", os.date(os.time()))))}] This strikes me as too complex (even for someone who cannot code). Is there now simpler way to write that? Just in case it may be relevant, this is part of the full day reference. Many thanks for your help, Pablo

Pablo Rodriguez via ntg-context schrieb am 06.12.2024 um 12:35:
Dear list,
I would like to get the current month in Roman numerals (just now, it would be XII for December).
The best I get is:
\currentdate[\cldcontext{converters['R'] (tonumber(os.date("\letterpercent m", os.date(os.time()))))}]
This strikes me as too complex (even for someone who cannot code).
Is there now simpler way to write that?
The \date (and \currentdate) command supports number conversion for the day and year values but not the month. \starttext \currentdate[d:R,space,space,y:R] \stoptext The simplest method is to use \convertnumber in combination with \normalmonth etc. which holds the value for the current month etc. \starttext \convertnumber{R}{\normalday }\textslash \convertnumber{R}{\normalmonth}\textslash \convertnumber{R}{\normalyear } \stoptext Wolfgang

On 12/6/24 15:39, Wolfgang Schuster wrote:
[...] The \date (and \currentdate) command supports number conversion for the day and year values but not the month.
\starttext \currentdate[d:R,space,space,y:R] \stoptext
Many thanks for your fast reply, Wolfgang. I didn’t even know that there were such short invocations for number conversions in \currentdate.
The simplest method is to use \convertnumber in combination with \normalmonth etc. which holds the value for the current month etc.
\starttext \convertnumber{R}{\normalday }\textslash \convertnumber{R}{\normalmonth}\textslash \convertnumber{R}{\normalyear } \stoptext
First time I see these commands. Good to know them. Many thanks for your help, Pablo

Any thoughts why the following doesn't work? \currentdate[d:persiannumerals] It just outputs the normal digits. In contrast, these work: \currentdate[d:abjadnumerals] \convertnumber{persiannumerals}{\normalday} On Sat, Dec 7, 2024, 7:11 AM Pablo Rodriguez via ntg-context < ntg-context@ntg.nl> wrote:
On 12/6/24 15:39, Wolfgang Schuster wrote:
[...] The \date (and \currentdate) command supports number conversion for the day and year values but not the month.
\starttext \currentdate[d:R,space,space,y:R] \stoptext
Many thanks for your fast reply, Wolfgang.
I didn’t even know that there were such short invocations for number conversions in \currentdate.
The simplest method is to use \convertnumber in combination with \normalmonth etc. which holds the value for the current month etc.
\starttext \convertnumber{R}{\normalday }\textslash \convertnumber{R}{\normalmonth}\textslash \convertnumber{R}{\normalyear } \stoptext
First time I see these commands. Good to know them.
Many thanks for your help,
Pablo
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________

Am 20.02.2025 um 19:53 schrieb Mohammad Hossein Bateni:
Any thoughts why the following doesn't work?
\currentdate[d:persiannumerals]
It just outputs the normal digits.
In contrast, these work:
\currentdate[d:abjadnumerals] \convertnumber{persiannumerals}{\normalday}
persiannumerals aren't considered a conversion method for the underlying Lua mechanism while there exists a method for \convertnumber on the TeX side. Both system are separate (to a certain degree) but the TeX side borrows the conversion vectors from the Lua mechanism. Wolfgang

For Jalali dates and Persian numbering, I can get the following to work: \persiandecimals{\rawdate[jalali:to,d]}/\persiandecimals{\rawdate[jalali:to,M]}/\persiandecimals{\rawdate[jalali:to,y]} but the following does not work and throws an error: \persiandecimals{\currentdate[jalali:to,d]} If I want to get the output for different date, option 1 below works and option 2 does not. --------- % option 1 \persiandecimals{\begingroup\setdate[m=5]\rawdate[jalali:to,y]\endgroup} % option 2 {\begingroup\setdate[m=5]\persiandecimals{\rawdate[jalali:to,y]}\endgroup} ---------- does \setdate expand to something non-empty? note that with the above ideas, we cannot get "mm" with leading zeros to work because \persiandecimals drops the leading zero. the following ugly hack works if I insist on using \currentdate to format the output and I want Indic digits. -------- \startluacode function persmap(s) local stream = tostring(s) local mapping = languages.decimals.persian local gsub = string.gsub return mapping and gsub(stream, ".", mapping) or stream end \stopluacode \def\persmap#1{\ctxlua{context(persmap("#1"))}} \def\mycurrentdate[#1]{\persmap{\rawdate[#1]}} \mycurrentdate[jalali:to,dd,/,mm,/,y] -------- even with \mainlanguage[fa] and \language[fa] I don't get the month names translated to persian labels. why? ------ \mainlanguage[fa] \language[fa] \starttext \currentdate[month:jalali] \stoptext ----- On Fri, Feb 21, 2025 at 12:13 PM Wolfgang Schuster < wolfgang.schuster.lists@gmail.com> wrote:
Am 20.02.2025 um 19:53 schrieb Mohammad Hossein Bateni:
Any thoughts why the following doesn't work?
\currentdate[d:persiannumerals]
It just outputs the normal digits.
In contrast, these work:
\currentdate[d:abjadnumerals] \convertnumber{persiannumerals}{\normalday}
persiannumerals aren't considered a conversion method for the underlying Lua mechanism while there exists a method for \convertnumber on the TeX side.
Both system are separate (to a certain degree) but the TeX side borrows the conversion vectors from the Lua mechanism.
Wolfgang
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________

the following outputs "farsi" instead of "fa". is this the reason the
translation of jalali month does not kick in?
------
\mainlanguage[fa]
\currentlanguage
------
strangely either of the following two lines changes the month name.
------
\setuplabeltext[en][february:jalali=test]
\setuplabeltext[fa][february:jalali=test]
\currentlanguage[month:jalali]
------
I'm confused. why isn't the data in lang-txt.lua used?
strangely, the following outputs the correct translation of second jalali
month in farsi regardless of the above \setuplabeltext commands:
----
\ctxlua{context(languages.data.labels.texts['february:jalali'].labels.fa)}
----
On Thu, Feb 27, 2025 at 6:30 AM Mohammad Hossein Bateni
For Jalali dates and Persian numbering, I can get the following to work:
\persiandecimals{\rawdate[jalali:to,d]}/\persiandecimals{\rawdate[jalali:to,M]}/\persiandecimals{\rawdate[jalali:to,y]}
but the following does not work and throws an error:
\persiandecimals{\currentdate[jalali:to,d]}
If I want to get the output for different date, option 2 below works and option 1 does not.
--------- % option 1 \persiandecimals{\begingroup\setdate[m=5]\rawdate[jalali:to,y]\endgroup} % option 2 {\begingroup\setdate[m=5]\persiandecimals{\rawdate[jalali:to,y]}\endgroup} ----------
does \setdate expand to something non-empty?
note that with the above ideas, we cannot get "mm" with leading zeros to work because \persiandecimals drops the leading zero. the following ugly hack works if I insist on using \currentdate to format the output and I want Indic digits.
-------- \startluacode function persmap(s) local stream = tostring(s) local mapping = languages.decimals.persian local gsub = string.gsub return mapping and gsub(stream, ".", mapping) or stream end \stopluacode
\def\persmap#1{\ctxlua{context(persmap("#1"))}} \def\mycurrentdate[#1]{\persmap{\rawdate[#1]}} \mycurrentdate[jalali:to,dd,/,mm,/,y] --------
even with \mainlanguage[fa] and \language[fa] I don't get the month names translated to persian labels. why?
------ \mainlanguage[fa] \language[fa] \starttext \currentdate[month:jalali] \stoptext -----
On Fri, Feb 21, 2025 at 12:13 PM Wolfgang Schuster < wolfgang.schuster.lists@gmail.com> wrote:
Am 20.02.2025 um 19:53 schrieb Mohammad Hossein Bateni:
Any thoughts why the following doesn't work?
\currentdate[d:persiannumerals]
It just outputs the normal digits.
In contrast, these work:
\currentdate[d:abjadnumerals] \convertnumber{persiannumerals}{\normalday}
persiannumerals aren't considered a conversion method for the underlying Lua mechanism while there exists a method for \convertnumber on the TeX side.
Both system are separate (to a certain degree) but the TeX side borrows the conversion vectors from the Lua mechanism.
Wolfgang
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________

BTW why doesn't \setuplabeltext exist in the mtx-server-ctx-help? It does
exist in setup-en.pdf and shows that it is an instance of \setupLABELtext.
On Fri, Feb 28, 2025 at 5:28 PM Mohammad Hossein Bateni
the following outputs "farsi" instead of "fa". is this the reason the translation of jalali month does not kick in?
------ \mainlanguage[fa] \currentlanguage ------
strangely either of the following two lines changes the month name.
------ \setuplabeltext[en][february:jalali=test] \setuplabeltext[fa][february:jalali=test] \currentlanguage[month:jalali] ------
I'm confused. why isn't the data in lang-txt.lua used? strangely, the following outputs the correct translation of second jalali month in farsi regardless of the above \setuplabeltext commands:
---- \ctxlua{context(languages.data.labels.texts['february:jalali'].labels.fa)} ----
On Thu, Feb 27, 2025 at 6:30 AM Mohammad Hossein Bateni
wrote: For Jalali dates and Persian numbering, I can get the following to work:
\persiandecimals{\rawdate[jalali:to,d]}/\persiandecimals{\rawdate[jalali:to,M]}/\persiandecimals{\rawdate[jalali:to,y]}
but the following does not work and throws an error:
\persiandecimals{\currentdate[jalali:to,d]}
If I want to get the output for different date, option 2 below works and option 1 does not.
--------- % option 1 \persiandecimals{\begingroup\setdate[m=5]\rawdate[jalali:to,y]\endgroup} % option 2 {\begingroup\setdate[m=5]\persiandecimals{\rawdate[jalali:to,y]}\endgroup} ----------
does \setdate expand to something non-empty?
note that with the above ideas, we cannot get "mm" with leading zeros to work because \persiandecimals drops the leading zero. the following ugly hack works if I insist on using \currentdate to format the output and I want Indic digits.
-------- \startluacode function persmap(s) local stream = tostring(s) local mapping = languages.decimals.persian local gsub = string.gsub return mapping and gsub(stream, ".", mapping) or stream end \stopluacode
\def\persmap#1{\ctxlua{context(persmap("#1"))}} \def\mycurrentdate[#1]{\persmap{\rawdate[#1]}} \mycurrentdate[jalali:to,dd,/,mm,/,y] --------
even with \mainlanguage[fa] and \language[fa] I don't get the month names translated to persian labels. why?
------ \mainlanguage[fa] \language[fa] \starttext \currentdate[month:jalali] \stoptext -----
On Fri, Feb 21, 2025 at 12:13 PM Wolfgang Schuster < wolfgang.schuster.lists@gmail.com> wrote:
Am 20.02.2025 um 19:53 schrieb Mohammad Hossein Bateni:
Any thoughts why the following doesn't work?
\currentdate[d:persiannumerals]
It just outputs the normal digits.
In contrast, these work:
\currentdate[d:abjadnumerals] \convertnumber{persiannumerals}{\normalday}
persiannumerals aren't considered a conversion method for the underlying Lua mechanism while there exists a method for \convertnumber on the TeX side.
Both system are separate (to a certain degree) but the TeX side borrows the conversion vectors from the Lua mechanism.
Wolfgang
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________

On 2/28/2025 11:30 PM, Mohammad Hossein Bateni wrote:
BTW why doesn't \setuplabeltext exist in the mtx-server-ctx-help? It does exist in setup-en.pdf and shows that it is an instance of \setupLABELtext.
because it's a 'defined command' ... i could probably add it but it's not like there has been much demand for it Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------

On 2/28/2025 11:28 PM, Mohammad Hossein Bateni wrote:
the following outputs "farsi" instead of "fa". is this the reason the translation of jalali month does not kick in?
We have these short and long names, and originally only had short ones, for efficiency reasons (like memory limitations in tex engines). At some point some showt nakes also started clashing, like \it : italian and italic. One can best use the long ones, while te shirt ones are used e.g. in lua data tables (easier). Teh fact that ther eis \fa is sort of 'good luck' because if we'd add a language today we don't define the short ones as command any longer (we keep the existing ones for compatibility). If you want to add a language (parent of child) you need to check that with Tomas Hala first because it has to into his label managagement project (with international students). When conversions are added, Wolfgang needs to agree with it. When okay it then can also be added to the interface (setups) specification. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------

On Sun, Mar 2, 2025, 8:00 AM Hans Hagen via ntg-context
On 2/28/2025 11:28 PM, Mohammad Hossein Bateni wrote:
the following outputs "farsi" instead of "fa". is this the reason the translation of jalali month does not kick in?
We have these short and long names, and originally only had short ones, for efficiency reasons (like memory limitations in tex engines). At some point some showt nakes also started clashing, like \it : italian and italic.
One can best use the long ones, while te shirt ones are used e.g. in lua data tables (easier). Teh fact that ther eis \fa is sort of 'good luck' because if we'd add a language today we don't define the short ones as command any longer (we keep the existing ones for compatibility).
This make sense. My point is not why the language shows up as farsi. The problem is that the labels in the lua table are for 'fa'. So farsi or fa language doesn't pick them up. See my example in previous emails (even for figure captions). What's the solution? To add a key to install language to say what short form should be used on lua side? Or to rewrite the lua table to use farsi as key not fa?
If you want to add a language (parent of child) you need to check that with Tomas Hala first because it has to into his label managagement project (with international students).
When conversions are added, Wolfgang needs to agree with it. When okay it then can also be added to the interface (setups) specification.
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
participants (4)
-
Hans Hagen
-
Mohammad Hossein Bateni
-
Pablo Rodriguez
-
Wolfgang Schuster