我正在尝试构建一个更正的版本,dt-welsh.def
以便与该包一起使用datetime
。部分原因是我现有的设置依赖于datetime
和,部分原因是因为datetime2
要复杂得多,而我不知道如何提供合适的语言模块。(有一个威尔士语模块,但它是不正确的,而且无人维护。)由于我真的不需要额外的复杂性,所以修复它会很好datetime
。
由于datetime
作者认为它已被弃用,因此威尔士语支持将不会得到修复。因此我想弄清楚如何修复,因为不会有官方修复。
代码在标准情况下工作正常,但在使用例如\shortdate
或时会引入虚假空格\longdate
,我不确定如何最好地消除它们。
标准日期格式:
短格式和长格式:
\documentclass[welsh]{article}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage{datetime}
\begin{document}
\day=0
\loop\ifnum\day<31
\advance\day by 1
\today
\endgraf
\repeat
\day=0
\loop\ifnum\day<31
\advance\day by 1
\longdate\today
\endgraf
\repeat
\day=0
\loop\ifnum\day<31
\advance\day by 1
\shortdate\today
\endgraf
\repeat
\end{document}
修改版本dt-welsh.def
:
%% dt-cymraeg.def
%% Additions and changes are copyright 2015 Clea F. Rees
%% Code from dt-welsh.def copyright 2015 Nicola Talbot (see below)
%% Code from gloss-welsh.ldf copyright 2008-2010 François Charette,
%% 2013 Élie Roux, 2011-2015 Arthur Reutenauer
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Clea F. Rees.
%
% This work consists of the file dt-cymraeg.def
%
% The file dt-cymraeg.def is a derived work under the terms of the
% LPPL. It is based on dt-welsh.def which is part of the datetime
% package by Nicola Talbot. A copy of datetime, including the
% unmodified version of dt-welsh.def is available from
% http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=datetime.
%
% The modifications are also derivative under the terms of the LPPL. They
% are based on code modified from gloss-welsh.ldf which is part of
% polyglossia 2015/08/06 v1.42.0 by François Charette, Élie Roux
% and Arthur Reutenauer. A copy of polyglossia, including gloss-welsh.ldf
% is available
% from http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=polyglossia.
%%
\ProvidesFile{dt-cymraeg.def}[$Id: dt-cymraeg.def 3789 2015-08-31 02:01:23Z cfrees $]
\providecommand*\dt@cymraeg@neges{%
\PackageWarning{dt-cymraeg.def}{This is a MODIFIED version of dt-welsh.def. Breakage should under no circumstances be blamed on the author of the original file.}}
\dt@cymraeg@neges
\renewcommand*\dt@cymraeg@neges{\relax}
\providecommand*\ordinaldatewelsh[1]{%
#1\ifcase#1\relax%
\or\textsuperscript{af}%
\or\textsuperscript{ail}%
\or\textsuperscript{ydd}%
\or\textsuperscript{ydd}%
\or\textsuperscript{ed}%
\or\textsuperscript{ed}%
\or\textsuperscript{fed}%
\or\textsuperscript{fed}%
\or\textsuperscript{fed}%
\or\textsuperscript{fed}%
\or\textsuperscript{eg}%
\or\textsuperscript{fed}%
\or\textsuperscript{eg}%
\or\textsuperscript{eg}%
\or\textsuperscript{fed}%
\or\textsuperscript{eg}%
\or\textsuperscript{eg}%
\or\textsuperscript{fed}%
\or\textsuperscript{eg}%
\or\textsuperscript{fed}%
\else\textsuperscript{ain}\fi}%
\global\let\ordinaldatewelsh\ordinaldatewelsh
\providecommand\dayofweeknameidwelsh[1]{%
dydd\space%
\ifcase#1\relax
\or Sul%
\or Llun%
\or Mawrth%
\or Mercher%
\or Iau%
\or Gwener%
\or Sadwrn%
\fi}%
\global\let\dayofweeknameidwelsh\dayofweeknameidwelsh
\providecommand{\shortdayofweeknameidwelsh}[1]{%
\ifcase#1\relax%
\or Sul%
\or Llun%
\or Maw.%
\or Mer.%
\or Iau%
\or Gwen.%
\or Sad.%
\fi}%
\global\let\shortdayofweeknameidwelsh\shortdayofweeknameidwelsh
\providecommand{\monthnamewelsh}[1][\month]{%
\@orgargctr=#1\relax%
\ifcase\@orgargctr%
\PackageError{datetime}{Invalid Month number \the\@orgargctr}{%
Month numbers should go from 1 to 12}%
\or Ionawr%
\or Chwefror%
\or Mawrth%
\or Ebrill%
\or Mai%
\or Mehefin%
\or Gorffennaf%
\or Awst%
\or Medi%
\or Hydref%
\or Tachwedd%
\or Rhagfyr%
\else%
\PackageError{datetime}{Invalid Month number \the\@orgargctr}{%
Month numbers should go from 1 to 12}%
\fi}%
\global\let\monthnamewelsh\monthnamewelsh
\DeclareRobustCommand*\datewelsh{%
\renewcommand{\formatdate}[3]{%
\@day=##1\relax\@month=##2\relax\@year=##3\relax
\number\@day%
\ifcase\@day\relax%
\or\textsuperscript{af}%
\or\textsuperscript{ail}%
\or\textsuperscript{ydd}%
\or\textsuperscript{ydd}%
\or\textsuperscript{ed}%
\or\textsuperscript{ed}%
\or\textsuperscript{fed}%
\or\textsuperscript{fed}%
\or\textsuperscript{fed}%
\or\textsuperscript{fed}%
\or\textsuperscript{eg}%
\or\textsuperscript{fed}%
\or\textsuperscript{eg}%
\or\textsuperscript{eg}%
\or\textsuperscript{fed}%
\or\textsuperscript{eg}%
\or\textsuperscript{eg}%
\or\textsuperscript{fed}%
\or\textsuperscript{eg}%
\or\textsuperscript{fed}%
\else\textsuperscript{ain}%
\fi%
\space%
\monthnamewelsh[\@month]\space\number\@year}%
}%
\global\let\datewelsh\datewelsh
\providecommand{\shortmonthnamewelsh}[1][\month]{%
\@orgargctr=#1\relax%
\ifcase\@orgargctr%
\PackageError{datetime}{Invalid Month number \the\@orgargctr}{%
Month numbers should go from 1 (jan.) to 12 (dec.)}% rhai o Yale ond 'dw i ddim yn cytuno â'i rhai Saesneg chwaith! (efaillai bod nhw'n safonol a ffurfiol?)
\or Ion.%
\or Chwe.% Chwef. yn ôl Yale??!!
\or Maw.%
\or Ebr.%
\or Mai%
\or Meh.%
\or Gorff.%
\or Awst.%
\or Medi%
\or Hyd.%
\or Tach.%
\or Rhag.%
\else%
\PackageError{datetime}{Invalid Month number \the\@orgargctr}{%
Month numbers should go from 1 (jan.) to 12 (dec.)}%
\fi}
\endinput
%%
%% End of file dt-cymraeg.def.
代码的背景和用途
看:https://tex.stackexchange.com/a/260784/背景、注意事项等。上面发布的代码是dt-welsh.def
基于的(部分)修复版本egreg 的回答,egreg 的评论gloss-welsh.ldf
以及从新版本更新的polyglossia
。
许可证不允许我发布修改后的版本dt-welsh.def
,我无法找到一种干净的方式来加载不同名称的文件。因此,这个文件被命名为dt-cymraeg.def
,但必须重命名为dt-welsh.def
才能真正工作。它不能以这种形式分发,但可以在您自己的系统上以这种形式使用。