Bug Tracker RSS feed

I’m currently working on a major new version of the datatool package. This may take a while. Please be patient. (Experimental version available for testing.)

ID 160🔗
Date: 2020-05-25 05:01:05
Status Closed (Not a Bug)
Category datetime2
Version v1.5.6
Summary Trigger language autodetection when setting language after loading datetime2

Sign in to subscribe to notifications about this report.

Description

Hello,

Thanks very much for contributing this excellent work to the CTAN!

I'm trying to use datetime2 in a custom template (document class definition), where the default language is not known until runtime. I would like my title page to receive a datetime2-set date (set using DTMsavedate) and then format it for display in the document locale (ie. including textual month).

However, it seems that datetime2 only scans the tracked languages when the package is loaded, and the subsequent functions cannot trigger a re-scan. I'm not sure if this is a limitation in datetime2 or in the tracklang class, and after perusing the source code of datetime, I still have no clue :-)

I'd be happy to try to fix this issue and submit a patch, but would need a pointer as to where to look in the code.

Best,

Jonathan

MWE

Download (792B)

\documentclass{article}

\usepackage{polyglossia}

% If you uncomment this line, the display date will
% appear in unlocalized form (numeric month)
% \usepackage[useregional]{datetime2}

\setdefaultlanguage[variant=american]{english}

\usepackage[useregional]{datetime2}

\begin{document}

% I want this to appear as: March 28, 2014 when
% \setdefaultlanguage is English, or mars 28, 2014
% when \setdefaultlanguage is French
%
% I'm using datetime2 in a document class, but
% definining document languages in the document
% that uses it, so the language is not set until
% after datetime2 is loaded.
%
% I need a method to force datetime2 to re-scan
% the list of tracked languages and check for
% corresponding installed modules.
\DTMdisplaydate{2014}{3}{28}{-1}

\end{document}

\endinput

Evaluation

It's documented that the languages must be setup before datetime2 is loaded, so therefore I have to close this as not a bug. However, it's possible to track additional languages after tracklang has been loaded using commands like \TrackPredefinedDialect or \TrackLanguageTag. You can then use datetime2's \DTMusemodule{dialect}{name} command to load the required language module. (\DTMusemodule automatically uses \TrackPredefinedDialect if the given dialect hasn't already been tracked.)

The actual code used by datetime2 to load all modules is:

\AnyTrackedLanguages
{%
  \ForEachTrackedDialect{\this@dialect}%
  {%
    \@dtm@requiremodule\this@dialect
  }%
}
{}%

This uses \AnyTrackedLanguages to test if any languages have been tracked and then uses \ForEachTrackedDialect to iterate over the list of all tracked dialect labels. The internal command \@dtm@requiremodule performs the actual loading using tracklang's \IfTrackedLanguageFileExists, which tries to determine the basename of the required .ldf language file.

Unfortunately, all of the language packages, such as babel and polyglossia, have their own idiosyncratic way of dealing with languages, so it's hard to provide a general method that easily integrates with all of them. See Localisation with tracklang.tex

Comments

0 comments.


Add Comment

Name (optional):

Are you human? Please confirm the bug report ID (which can be found at the top of this page) or login if you have an account.

Comment:


You can use the following markup:

Block:

[pre]Displayed verbatim[/pre]
[quote]block quote[/quote]

In line:

[tt]code[/tt]
[file]file/package/class name[/file]
[em]emphasized text[/em]
[b]bold text[/b]
[url]web address[/url] [sup]superscript[/sup]
[sub]subscript[/sub]

Ordered list:
[ol]
[li]first item[/li]
[li]second item[/li]
[/ol]

Unordered list:
[ul]
[li]first item[/li]
[li]second item[/li]
[/ul]

You can use the Preview button to review your message formatting before submitting.

Page permalink: https://www.dickimaw-books.com/bugtracker.php?key=160