Latest news 2024-03-02: Ebook sale (3rd–9th March 2024): short story cybercrime fiction Unsocial Media free; short story noir crime fiction I’ve Heard the Mermaid Sing free; crime fiction novel The Private Enemy US$1.99; illustrated children’s story The Foolish Hedgehog US$0.99. For further details, see latest blog post.

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.



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.




Download (792B)



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




% 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.




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:


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



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.


You can use the following markup:


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

In line:

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

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

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

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

Page permalink: