Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch all captions which interact with numbers to parameterized captions #368

Open
BrianCriswell opened this issue Dec 18, 2024 · 1 comment

Comments

@BrianCriswell
Copy link
Member

BrianCriswell commented Dec 18, 2024

There are still some places where parameterized captions are needed to handle languages which do not order words and numbers in the same order as English. Known issues include:

#190
#213
#324

One place where we already handle this is in the #/day text of innate spellcasting.

\NewDocumentCommand {\DndInnateSpellLevel} { O {\innateatwillname} m }
{
\item
[
\regex_match:NnTF \c__pos_int_regex {#1}
{
\str_if_in:NnTF {#2} {,}
{ \__dnd_caption:nn {\numberperdayeachname} {#1} }
{ \__dnd_caption:nn {\numberperdayname} {#1} }
}
{#1}
:
]
\DndEmphSpellString {#2}
}

These situations use the following command.

% \addto\captions<language> cannot handle macros with parameters
% We need to make our own parameters
% |1| represents parameter 1
\cs_new_protected:Npn \__dnd_caption:nn #1#2
{
\group_begin:
\str_set:Nx \l_tmpa_str { #1 }
\str_set:Nx \l_tmpb_str { #2 }
\exp_args:NNnx \str_replace_all:Nnn \l_tmpa_str { |1| } { #2 }
\str_use:N \l_tmpa_str
\group_end:
}

@xrogaan
Copy link

xrogaan commented Dec 18, 2024

While talking number and l10n, you may possibly want to replace numprint with siunitx. It's a lot more powerful, allows for custom units and seems to handle locale pretty well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants