40 lines
1.3 KiB
TeX
40 lines
1.3 KiB
TeX
\NeedsTeXFormat{LaTeX2e}
|
|
\ProvidesPackage{dictionary}[2024/11/24 Dictionary]
|
|
|
|
\RequirePackage{babel}
|
|
\RequirePackage{datatool}
|
|
|
|
\DeclareKeys[dictionary]{
|
|
primary.store = \@dictionary@primary,
|
|
secondary.store = \@dictionary@secondary
|
|
}
|
|
|
|
\ProcessKeyOptions[dictionary]
|
|
|
|
\PassOptionsToPackage{\@dictionary@primary,\@dictionary@secondary}{babel}
|
|
|
|
\newcommand{\previouslang}{\languagename}
|
|
%% \newcommand{\selectpreviouslang}{\selectlanguage{\languagename}}
|
|
|
|
\newcommand{\debugDictionary}{primary: \@dictionary@primary, secondary: \@dictionary@secondary, previous: \previouslang}
|
|
|
|
\newcommand{\entry}[2]{%
|
|
\DTLnewrow{dictionary}%
|
|
\DTLnewdbentry{dictionary}{word}{#1}%
|
|
\DTLnewdbentry{dictionary}{translation}{#2}%
|
|
}
|
|
|
|
\newenvironment{dictionary}{%
|
|
\DTLifdbexists{dictionary}{\DTLcleardb{dictionary}}{\DTLnewdb{dictionary}}%
|
|
}{%
|
|
\renewcommand{\previouslang}{\languagename}
|
|
%% \renewcommand{\selectpreviouslang}{\selectlanguage{\languagename}}
|
|
\DTLsort{word}{dictionary}%
|
|
\scriptsize%
|
|
\DTLforeach*{dictionary}{\word=word,\translation=translation}{%
|
|
\selectlanguage{\@dictionary@primary}\textbf{\word:} \selectlanguage{\@dictionary@secondary}\translation\\}%
|
|
%% \selectlanguage{vietnamese}\textbf{\word:} \selectlanguage{naustrian}\translation\\}%
|
|
\selectlanguage{\@dictionary@primary}%
|
|
%% \selectlanguage{\previouslang}%
|
|
%% \selectpreviouslang
|
|
}
|