Skip to content
Permalink
Browse files

japanese.dtx: new era 'reiwa'

  • Loading branch information...
aminophen committed Apr 3, 2019
1 parent aa2068e commit 62d45f4d92577a68fee5c13842a12d695901c107
Showing with 166 additions and 58 deletions.
  1. +80 −33 japanese.dtx
  2. +63 −25 japanese.ldf
  3. +23 −0 tests/japanese_era.tex
@@ -4,26 +4,27 @@
% providing Japanese language support for Babel.
%
% Copyright (C) 1999--2007 by ING (Toru INAGAKI)
% 2016-- by Japanese TeX Development Community
% 2016--2019 by Japanese TeX Development Community
%
% This package 'japanese.dtx' supports the following Babel package:
%
% ====================================================================
%
% Copyright 2012-2016 Javier Bezos and Johannes L. Braams.
% Copyright 1989-2012 Johannes L. Braams and any individual authors
% listed elsewhere in this file. All rights reserved.
%
% Copyright (C) 2012-2018 Javier Bezos and Johannes L. Braams.
% Copyright (C) 1989-2012 Johannes L. Braams and
% any individual authors listed elsewhere in this file.
% All rights reserved.
%
% It 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 2003/12/01 or later.
%
%
% This work has the LPPL maintenance status "maintained".
%
%
% The Current Maintainer of this work is Javier Bezos.
%
% ====================================================================
@@ -45,7 +46,7 @@
%<code>\ProvidesLanguage{japanese}
%<*!sample>
%\ProvidesFile{japanese.dtx}
[2017/02/05 v2.1 Japanese support for babel (texjporg)]
[2019/04/03 v2.2 Japanese support for babel (texjporg)]
%</!sample>
%\fi
%
@@ -303,11 +304,9 @@
% 再定義します。デフォルトの出力は西暦です。和暦を使用する際は,プリアンブルで
% |\和暦| を指定するか,本文で |\和暦\today| のように指定します。
%
% フラグの準備,平成の計算
% フラグの準備。
% \begin{macrocode}
\newif\ifbbl@jpn@Seireki \bbl@jpn@Seirekitrue
{\advance\year-1988\relax
\xdef\the@heisei{\the\year}}
% \end{macrocode}
%
% Unicodeな\TeX{}エンジン(Xe\TeX{},Lua\TeX{})の場合は,
@@ -317,20 +316,24 @@
\ifx\kanjiskip\@undefined
\def\西暦{\bbl@jpn@Seirekitrue}%
\def\和暦{\bbl@jpn@Seirekifalse}%
\def\bbl@jpn@kanjishowa{昭和}
\def\bbl@jpn@kanjiheisei{平成}
\def\bbl@jpn@kanjireiwa{令和}
\def\bbl@jpn@kanjigan{元}%
\def\bbl@jpn@TateSeirekiToday{%
\bbl@jpn@maybekansuji\year%
\bbl@jpn@maybekansuji\month%
\bbl@jpn@maybekansuji\day 日}
\def\bbl@jpn@TateWarekiToday{%
平成\bbl@jpn@maybekansuji\the@heisei%
\bbl@jpn@gengo\bbl@jpn@maybekansuji\bbl@jpn@gengoyear%
\bbl@jpn@maybekansuji\month%
\bbl@jpn@maybekansuji\day 日}
\def\bbl@jpn@SeirekiToday{%
\number\year%
\number\month%
\number\day 日}
\def\bbl@jpn@WarekiToday{%
平成\the@heisei%
\bbl@jpn@gengo\number\bbl@jpn@gengoyear%
\number\month%
\number\day 日}
% \end{macrocode}
@@ -339,42 +342,77 @@
% \begin{macrocode}
\else
\begingroup
\kansujichar1=\jis"472F\relax %
\kansujichar2=\jis"376E\relax %
\kansujichar3=\jis"467C\relax %
\xdef\bbl@jpn@kanjinen{\kansuji1}%
\xdef\bbl@jpn@kanjigatsu{\kansuji2}%
\xdef\bbl@jpn@kanjinichi{\kansuji3}%
\kansujichar1=\jis"403E\relax % 西
\kansujichar2=\jis"4F42\relax %
\kansujichar3=\jis"4E71\relax %
\expandafter\expandafter\expandafter\gdef
\expandafter\csname\kansuji13\endcsname{\bbl@jpn@Seirekitrue}%
\expandafter\expandafter\expandafter\gdef
\expandafter\csname\kansuji23\endcsname{\bbl@jpn@Seirekifalse}%
\kansujichar1=\jis"472F\relax %
\kansujichar2=\jis"376E\relax %
\kansujichar3=\jis"467C\relax %
\kansujichar4=\jis"4A3F\relax %
\kansujichar5=\jis"402E\relax %
\xdef\bbl@jpn@kanjinen{\kansuji1}%
\xdef\bbl@jpn@kanjigatsu{\kansuji2}%
\xdef\bbl@jpn@kanjinichi{\kansuji3}%
\kansujichar6=\jis"3E3C\relax %
\kansujichar7=\jis"4E61\relax %
\xdef\bbl@jpn@kanjishowa{\kansuji62}%
\xdef\bbl@jpn@kanjiheisei{\kansuji45}%
\xdef\bbl@jpn@kanjireiwa{\kansuji72}%
\kansujichar0=\jis"3835\relax %
\xdef\bbl@jpn@kanjigan{\kansuji0}%
\endgroup
\def\bbl@jpn@TateSeirekiToday{%
\bbl@jpn@maybekansuji\year\bbl@jpn@kanjinen
\bbl@jpn@maybekansuji\month\bbl@jpn@kanjigatsu
\bbl@jpn@maybekansuji\day\bbl@jpn@kanjinichi}
\def\bbl@jpn@TateWarekiToday{%
\bbl@jpn@kanjiheisei\bbl@jpn@maybekansuji\the@heisei\bbl@jpn@kanjinen
\bbl@jpn@gengo\bbl@jpn@maybekansuji\bbl@jpn@gengoyear\bbl@jpn@kanjinen
\bbl@jpn@maybekansuji\month\bbl@jpn@kanjigatsu
\bbl@jpn@maybekansuji\day\bbl@jpn@kanjinichi}
\def\bbl@jpn@SeirekiToday{%
\number\year\bbl@jpn@kanjinen
\number\month\bbl@jpn@kanjigatsu
\number\day\bbl@jpn@kanjinichi}
\def\bbl@jpn@WarekiToday{%
\bbl@jpn@kanjiheisei\the@heisei\bbl@jpn@kanjinen
\bbl@jpn@gengo\number\bbl@jpn@gengoyear\bbl@jpn@kanjinen
\number\month\bbl@jpn@kanjigatsu
\number\day\bbl@jpn@kanjinichi}
\fi
% \end{macrocode}
%
% |\bbl@jpn@gengo| の内部で,元号を計算します。
%
% [2019-04-03] 2019年5月1日から始まる予定の新元号「令和」に対応しました。
% \begin{macrocode}
\def\bbl@jpn@gengo#1\bbl@jpn@gengoyear{%
\@tempcnta\year\relax
\multiply\@tempcnta100
\advance\@tempcnta\month
\multiply\@tempcnta100
\advance\@tempcnta\day
\@tempcntb\year\relax
\ifnum\@tempcnta<19890108
\bbl@jpn@kanjishowa
\advance\@tempcntb-1925
\else\ifnum\@tempcnta<20190501
\bbl@jpn@kanjiheisei
\advance\@tempcntb-1988
\else
\bbl@jpn@kanjireiwa
\advance\@tempcntb-2018
\fi\fi
\ifnum\@tempcntb=1
\bbl@jpn@kanjigan % 元年は \number も \kansuji も関係ない
\else
#1\@tempcntb % この #1 は \number または \bbl@jpn@maybekansuji
\fi
}
% \end{macrocode}
%
% (u)p\LaTeXe{}とLua\TeX-jaで組方向判定方法が異なるため,|\catcode| のトリックで
% 別々のコードを使い分けます。Xe\LaTeX{}の場合,およびLua\LaTeX{}でLua\TeX-ja不使用の
% 場合は,縦組をサポートしません。
@@ -406,23 +444,32 @@
% \end{macrocode}
%
% 実際に使用する命令にコピーします。
%
% [2019-04-03] 縦数式ディレクションは横組と同じ出力とします。
% \begin{macrocode}
\@namedef{date\CurrentOption}{%
\def\today{%
P \iftdir
L \ifnum\ltjgetparameter{direction}=3
X \ifbbl@jpn@Seireki
X \bbl@jpn@TateSeirekiToday
P \iftdir\ifmdir % tate-math
P \ifbbl@jpn@Seireki
P \bbl@jpn@SeirekiToday
P \else
P \bbl@jpn@WarekiToday
P \fi
P \else % tate
L \ifnum\ltjgetparameter{direction}=3 % tate
X \ifbbl@jpn@Seireki
X \bbl@jpn@TateSeirekiToday
X \else
X \bbl@jpn@TateWarekiToday
X \fi
P \fi
X \else
X \bbl@jpn@TateWarekiToday
\ifbbl@jpn@Seireki
\bbl@jpn@SeirekiToday
\else
\bbl@jpn@WarekiToday
\fi
X \fi
X \else
\ifbbl@jpn@Seireki
\bbl@jpn@SeirekiToday
\else
\bbl@jpn@WarekiToday
\fi
X \fi
}%
}
% \end{macrocode}
@@ -28,7 +28,7 @@
\epTeXinputencoding utf8
\fi
\ProvidesLanguage{japanese}
[2017/02/05 v2.1 Japanese support for babel (texjporg)]
[2019/04/03 v2.2 Japanese support for babel (texjporg)]
\ifx\kanjiskip\@undefined\ifx\directlua\@undefined
\ifx\XeTeXversion\@undefined
\@latex@error{Option '\CurrentOption' requires one of the followings:\MessageBreak
@@ -150,63 +150,94 @@
\let\glossaryname\bbl@jpn@glossaryname
}
\newif\ifbbl@jpn@Seireki \bbl@jpn@Seirekitrue
{\advance\year-1988\relax
\xdef\the@heisei{\the\year}}
\ifx\kanjiskip\@undefined
\def\西暦{\bbl@jpn@Seirekitrue}%
\def\和暦{\bbl@jpn@Seirekifalse}%
\def\bbl@jpn@kanjishowa{昭和}
\def\bbl@jpn@kanjiheisei{平成}
\def\bbl@jpn@kanjireiwa{令和}
\def\bbl@jpn@kanjigan{元}%
\def\bbl@jpn@TateSeirekiToday{%
\bbl@jpn@maybekansuji\year 年%
\bbl@jpn@maybekansuji\month 月%
\bbl@jpn@maybekansuji\day 日}
\def\bbl@jpn@TateWarekiToday{%
平成\bbl@jpn@maybekansuji\the@heisei 年%
\bbl@jpn@gengo\bbl@jpn@maybekansuji\bbl@jpn@gengoyear 年%
\bbl@jpn@maybekansuji\month 月%
\bbl@jpn@maybekansuji\day 日}
\def\bbl@jpn@SeirekiToday{%
\number\year 年%
\number\month 月%
\number\day 日}
\def\bbl@jpn@WarekiToday{%
平成\the@heisei 年%
\bbl@jpn@gengo\number\bbl@jpn@gengoyear 年%
\number\month 月%
\number\day 日}
\else
\begingroup
\kansujichar1=\jis"472F\relax % 年
\kansujichar2=\jis"376E\relax % 月
\kansujichar3=\jis"467C\relax % 日
\xdef\bbl@jpn@kanjinen{\kansuji1}%
\xdef\bbl@jpn@kanjigatsu{\kansuji2}%
\xdef\bbl@jpn@kanjinichi{\kansuji3}%
\kansujichar1=\jis"403E\relax % 西
\kansujichar2=\jis"4F42\relax % 和
\kansujichar3=\jis"4E71\relax % 暦
\expandafter\expandafter\expandafter\gdef
\expandafter\csname\kansuji13\endcsname{\bbl@jpn@Seirekitrue}%
\expandafter\expandafter\expandafter\gdef
\expandafter\csname\kansuji23\endcsname{\bbl@jpn@Seirekifalse}%
\kansujichar1=\jis"472F\relax % 年
\kansujichar2=\jis"376E\relax % 月
\kansujichar3=\jis"467C\relax % 日
\kansujichar4=\jis"4A3F\relax % 平
\kansujichar5=\jis"402E\relax % 成
\xdef\bbl@jpn@kanjinen{\kansuji1}%
\xdef\bbl@jpn@kanjigatsu{\kansuji2}%
\xdef\bbl@jpn@kanjinichi{\kansuji3}%
\kansujichar6=\jis"3E3C\relax % 昭
\kansujichar7=\jis"4E61\relax % 令
\xdef\bbl@jpn@kanjishowa{\kansuji62}%
\xdef\bbl@jpn@kanjiheisei{\kansuji45}%
\xdef\bbl@jpn@kanjireiwa{\kansuji72}%
\kansujichar0=\jis"3835\relax % 元
\xdef\bbl@jpn@kanjigan{\kansuji0}%
\endgroup
\def\bbl@jpn@TateSeirekiToday{%
\bbl@jpn@maybekansuji\year\bbl@jpn@kanjinen
\bbl@jpn@maybekansuji\month\bbl@jpn@kanjigatsu
\bbl@jpn@maybekansuji\day\bbl@jpn@kanjinichi}
\def\bbl@jpn@TateWarekiToday{%
\bbl@jpn@kanjiheisei\bbl@jpn@maybekansuji\the@heisei\bbl@jpn@kanjinen
\bbl@jpn@gengo\bbl@jpn@maybekansuji\bbl@jpn@gengoyear\bbl@jpn@kanjinen
\bbl@jpn@maybekansuji\month\bbl@jpn@kanjigatsu
\bbl@jpn@maybekansuji\day\bbl@jpn@kanjinichi}
\def\bbl@jpn@SeirekiToday{%
\number\year\bbl@jpn@kanjinen
\number\month\bbl@jpn@kanjigatsu
\number\day\bbl@jpn@kanjinichi}
\def\bbl@jpn@WarekiToday{%
\bbl@jpn@kanjiheisei\the@heisei\bbl@jpn@kanjinen
\bbl@jpn@gengo\number\bbl@jpn@gengoyear\bbl@jpn@kanjinen
\number\month\bbl@jpn@kanjigatsu
\number\day\bbl@jpn@kanjinichi}
\fi
\def\bbl@jpn@gengo#1\bbl@jpn@gengoyear{%
\@tempcnta\year\relax
\multiply\@tempcnta100
\advance\@tempcnta\month
\multiply\@tempcnta100
\advance\@tempcnta\day
\@tempcntb\year\relax
\ifnum\@tempcnta<19890108
\bbl@jpn@kanjishowa
\advance\@tempcntb-1925
\else\ifnum\@tempcnta<20190501
\bbl@jpn@kanjiheisei
\advance\@tempcntb-1988
\else
\bbl@jpn@kanjireiwa
\advance\@tempcntb-2018
\fi\fi
\ifnum\@tempcntb=1
\bbl@jpn@kanjigan % 元年は \number も \kansuji も関係ない
\else
#1\@tempcntb % この #1 は \number または \bbl@jpn@maybekansuji
\fi
}
\chardef\bbl@jpn@l@catcode=\catcode`\L\relax
\chardef\bbl@jpn@p@catcode=\catcode`\P\relax
\chardef\bbl@jpn@x@catcode=\catcode`\X\relax
@@ -233,20 +264,27 @@
\fi
\@namedef{date\CurrentOption}{%
\def\today{%
P \iftdir
L \ifnum\ltjgetparameter{direction}=3
X \ifbbl@jpn@Seireki
X \bbl@jpn@TateSeirekiToday
P \iftdir\ifmdir % tate-math
P \ifbbl@jpn@Seireki
P \bbl@jpn@SeirekiToday
P \else
P \bbl@jpn@WarekiToday
P \fi
P \else % tate
L \ifnum\ltjgetparameter{direction}=3 % tate
X \ifbbl@jpn@Seireki
X \bbl@jpn@TateSeirekiToday
X \else
X \bbl@jpn@TateWarekiToday
X \fi
P \fi
X \else
X \bbl@jpn@TateWarekiToday
\ifbbl@jpn@Seireki
\bbl@jpn@SeirekiToday
\else
\bbl@jpn@WarekiToday
\fi
X \fi
X \else
\ifbbl@jpn@Seireki
\bbl@jpn@SeirekiToday
\else
\bbl@jpn@WarekiToday
\fi
X \fi
}%
}
\let\bbl@jpn@maybekansuji\number
@@ -0,0 +1,23 @@
\documentclass{jarticle}
\usepackage[japanese]{babel}
\usepackage{plext}

\def\TEST{{\par\和\TESTa\西\TESTa\par}}
\def\TESTa{%
\today\par
\year=1926 \month=12 \day=31 \today\par
\year=1989 \month=01 \day=07 \today\par
\year=1989 \month=01 \day=08 \today\par
\year=2019 \month=04 \day=30 \today\par
\year=2019 \month=05 \day=01 \today\par
}
\begin{document}
\parindent0pt

\TEST

\parbox<t>{20zw}{\TEST}

\parbox<t>{20zw}{\parbox<z>{20zw}{\TEST}}

\end{document}

0 comments on commit 62d45f4

Please sign in to comment.
You can’t perform that action at this time.