1

I'm trying to automate report generation in czech. In english, there is no problem using solution from this thread. Same behaviour is for \monthname command from datetime package.

The problem is, that in czech the \DTMmonthname returns the month name in genitive case which is usually different from the nominative case.

Is datetime2 package capable of returning different cases (in czech there are 7 different cases, in german there are 4 cases) or it holds only one case for each month? Or there is only one way: hardcode \foo[<case>]{<month#>} by myself?

Crowley
  • 4,297
  • Have you tried \DTMMonthname{1}, with a capital M? – Runar Sep 06 '16 at 17:12
  • See the solutions to this question (especially Nicola Talbot's answer): Change month names in \today command – Alenanno Sep 06 '16 at 17:27
  • @RunarTrollet Yes, both capitalised and uncapitalised commands return genitive case. – Crowley Sep 06 '16 at 17:34
  • @Alenanno So the "hardcoding" then? The reason is that the sencences "[written on] January 7, 2016" and "Report for January, 2016" use different cases. – Crowley Sep 06 '16 at 17:40
  • Yeah, I didn't find anything in the manual about cases (in the grammatical sense), so I guess the only solution would be hardcoding. For the various "cases", no pun intended, you could use an optional argument to switch. But you still must add all the variants in the command definition manually. Unless someone thinks of a different solution. – Alenanno Sep 06 '16 at 17:44
  • @Alenanno This is the <case> option in sugegsted \foo command... Thanks for your suggestions anyway. – Crowley Sep 06 '16 at 17:47
  • Yes, I know that's what you suggested. I was agreeing with that. – Alenanno Sep 06 '16 at 17:49
  • The problem is that the relevant package datetime2-czech is unmaintained and probably always has been unmaintained. Therefore, the support for Czech is going to be pretty generic and minimal. The problem in finding a maintainer is likely to be that it needs somebody who can understand datetime2 and not just somebody with knowledge of Czech. I tried to understand datetime2 and failed. Hence, I'm using datetime with a corrected set of language definitions for my language. (Neither datetime nor datetime2 use correct translations of basic things as the original Babel was wrong.) – cfr Sep 06 '16 at 20:45
  • @cfr Another question is whether this case case is problem only for Czech and Slovak or there are other languages that may use different spellings for different cases. – Crowley Sep 06 '16 at 22:58
  • It isn't different cases, but, in Welsh, the initial letter of some month and day names varies according to context, as do the words for 'month' and 'day'. However, since the current package is essentially an usable mix of Welsh and Breton, such niceties are not really a pressing problem. But whether it is specific to Czech or not isn't directly relevant, except that you might hope somebody else had written code you could use and modify :-). – cfr Sep 06 '16 at 23:06
  • The vast majority of languages are supported by packages which are simply unmaintained. There isn't really good support for date/time localisation at present. – cfr Sep 06 '16 at 23:10

1 Answers1

2

I don't know any Czech, so this is pure guesswork.

The datetime2-serbian module provides Latin month names and Cyrillic month names with an option to switch between them. The datetime2-usorbian module provides new style month names and old style month names with an option to switch between them. It sounds as though you're looking for a similar function, so I'll use a similar method here to that employed by those language modules. If this isn't correct, please add some examples of usage to your question.

In datetime2-czech-utf8.ldf, replace

\newcommand*{\DTMczechmonthname}[1]{%
  \ifcase#1
  \or
  ledna%
  \or
  února%
  \or
  března%
  \or
  dubna%
  \or
  května%
  \or
  června%
  \or
  července%
  \or
  srpna%
  \or
  září%
  \or
  října%
  \or
  listopadu%
  \or
  prosince%
  \fi
}

with

\newcommand*{\DTMczechgenitivemonthname}[1]{%
  \ifcase#1
  \or
  ledna%
  \or
  února%
  \or
  března%
  \or
  dubna%
  \or
  května%
  \or
  června%
  \or
  července%
  \or
  srpna%
  \or
  září%
  \or
  října%
  \or
  listopadu%
  \or
  prosince%
  \fi
}
\newcommand*{\DTMczechmonthname}{\DTMczechgenitivemonthname}% default

\newcommand*{\DTMczechnominativemonthname}[1]{%
  \ifcase#1
  \or
  nominative version of ledna%
  \or
  nominative version of února%
  \or
  nominative version of března%
  \or
  nominative version of dubna%
  \or
  nominative version of května%
  \or
  nominative version of června%
  \or
  nominative version of července%
  \or
  nominative version of srpna%
  \or
  nominative version of září%
  \or
  nominative version of října%
  \or
  nominative version of listopadu%
  \or
  nominative version of prosince%
  \fi
}

Add similar code for the other cases that are required. Similarly for the first letter upper case \DTMczechMonthname.

Do the same thing in datetime2-czech-ascii.ldf but replace the UTF-8 characters with LaTeX commands. (The -utf8.ldf file is used by XeLaTeX and LuaLaTeX. The -ascii.ldf file is used by LaTeX.)

Then in datetime2-czech.ldf in the block that defines the module options (commands like \DTMdefbool and \DTMdefkey) add the following:

\DTMdefchoicekey{czech}{month}[\val\nr]{genitive,nominative}{%
 \ifcase\nr\relax
  \renewcommand*\DTMczechmonthname{\DTMczechgenitivemonthname}%
  \renewcommand*\DTMczechMonthname{\DTMczechgenitiveMonthname}%
 \or
  \renewcommand*\DTMczechmonthname{\DTMczechnominativemonthname}%
  \renewcommand*\DTMczechMonthname{\DTMczechnominativeMonthname}%
 \fi
}

Similarly add the extra cases that you require.

With these changes, in your document you should be able to switch between the different cases using \DTMlangsetup. For example:

\DTMlangsetup[czech]{month=genitive}
Nicola Talbot
  • 41,153