summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/fmtcount/fc-lang.tex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/fmtcount/fc-lang.tex
Initial commit
Diffstat (limited to 'macros/latex/contrib/fmtcount/fc-lang.tex')
-rw-r--r--macros/latex/contrib/fmtcount/fc-lang.tex356
1 files changed, 356 insertions, 0 deletions
diff --git a/macros/latex/contrib/fmtcount/fc-lang.tex b/macros/latex/contrib/fmtcount/fc-lang.tex
new file mode 100644
index 0000000000..b2a8907ffb
--- /dev/null
+++ b/macros/latex/contrib/fmtcount/fc-lang.tex
@@ -0,0 +1,356 @@
+ % This file is public domain
+
+ % This is an interactive script. Run it through \LaTeX
+ % and enter appropriate responses. (This won't work with
+ % LaTeX2HTML)
+
+\documentclass[a4paper]{article}
+
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+
+\usepackage{etoolbox}
+
+\usepackage[french,english,spanish,portuges,ngerman,italian]{babel}
+\usepackage{fmtcount}
+
+\newcounter{startval}
+\newcounter{endval}
+\newcounter{stepsize}
+\newcounter{N}
+\newcount\myctr
+\newcount\langid
+
+\newcommand*{\deflangopt}[2][\relax]{%
+ \csdef{setlang#2}{\langid=#2#1}%
+}
+\newcommand*{\uselangopt}[1]{\csuse{setlang#1}}
+\deflangopt{1}
+\deflangopt{2}
+\deflangopt{3}
+\deflangopt[\fmtcountsetoptions{french}]{4}
+\deflangopt[\fmtcountsetoptions{french=swiss}]{5}
+\deflangopt[\fmtcountsetoptions{french=belgian}]{6}
+\deflangopt{7}
+\deflangopt{8}
+
+\newcommand*{\defformat}[1]{%
+ \csdef{setformat#1}{\numformat=#1\relax}%
+}
+\newcommand*{\useformat}[1]{\csuse{setformat#1}}
+
+\newcommand*{\setformat}{\numformat=1\relax}
+
+\defformat{1}
+\defformat{2}
+\defformat{3}
+\defformat{4}
+\defformat{5}
+\defformat{6}
+
+\newcommand*{\defgender}[2]{%
+ \csdef{setgender#1}{\myctr=#2\relax}%
+}
+\newcommand*{\usegender}[1]{\csuse{setgender#1}}
+
+\defgender{}{1}
+\defgender{m}{1}
+\defgender{f}{2}
+\defgender{n}{3}
+
+\begin{document}
+
+\section{Displaying the value of a counter}
+
+\typeout{This is an interactive script, testing the fmtcount package.}
+
+\langid=-1
+
+\loop
+ \typeout{Which language?^^J}
+ \typeout{[1] English}
+ \typeout{[2] Portuguese}
+ \typeout{[3] Spanish}
+ \typeout{[4] French}
+ \typeout{[5] French (Swiss)}
+ \typeout{[6] French (Belgium)}
+ \typeout{[7] German}
+ \typeout{[8] Italian}
+
+ \typein[\response]{}
+
+ \ifcsundef{setlang\response}%
+ {%
+ \typeout{Invalid response '\response', please select a number from 1 to 8}%
+ \langid=-1\relax
+ }%
+ {\uselangopt{\response}}
+
+\ifnum\langid=-1
+\repeat
+
+\ifcase\langid
+\or \selectlanguage{english}
+Current language: English.
+\or \selectlanguage{portuges}
+Current language: Portuguese.
+\or \selectlanguage{spanish}
+Current language: Spanish.
+\or \selectlanguage{french}
+Current language: French.
+\or \selectlanguage{french}
+Current language: French (Swiss).
+\or \selectlanguage{french}
+Current language: French (Belgium).
+\or \selectlanguage{ngerman}
+Current language: German.
+\or \selectlanguage{italian}
+Current language: Italian.
+\fi
+
+\def\startval{-1}
+
+\loop
+ \typein[\startval]{Start value? (Integer from 0 to 99999) [Default 1]}
+ \ifdefempty{\startval}{\def\startval{1}}{}
+ \ifnum\startval<0\def\startval{-1}\fi
+ \ifnum\startval>99999\def\startval{-1}\fi
+
+\ifnum\startval=-1
+\repeat
+
+\def\endval{-1}
+
+\loop
+ \typein[\endval]{End value? (Integer from 0 to 99999) [Default 1000]}
+ \ifdefempty{\endval}{\def\endval{1000}}{}
+ \ifnum\endval<0\def\endval{-1}\fi
+ \ifnum\endval>99999\def\endval{-1}\fi
+\ifnum\endval=-1
+\repeat
+
+\def\stepsize{0}
+
+\loop
+ \typein[\stepsize]{Step size? (Non zero integer) [Default 1]}
+ \ifdefempty{\stepsize}{\def\stepsize{1}}{}
+\ifnum\stepsize=0
+\repeat
+
+\typeout{From {\startval} to {\endval} step {\stepsize}}
+
+\ifnum\startval<\endval\relax
+ \ifnum\stepsize<0\relax
+ \PackageError{fc-lang}{Infinite loop not permitted!}{}
+ \def\endval{\startval}
+ \fi
+\fi
+
+\ifnum\startval>\endval\relax
+ \ifnum\stepsize>0\relax
+ \PackageError{fc-lang}{Infinite loop not permitted!}{}
+ \def\endval{\startval}
+ \fi
+\fi
+
+\newcount\numformat
+
+\numformat=-1
+\loop
+ \typeout{Which format?^^J}
+ \typeout{[1] ordinalstring}
+ \typeout{[2] Ordinalstring}
+ \typeout{[3] ORDINALstring}
+ \typeout{[4] numberstring}
+ \typeout{[5] Numberstring}
+ \typeout{[6] NUMBERstring}
+
+ \typein[\response]{Default: 1}
+
+ \ifcsundef{setformat\response}%
+ {%
+ \numformat=-1\relax
+ \typeout{Invalid response '\response', please select a number from 1 to 6}%
+ }%
+ {%
+ \useformat\response
+ }
+
+\ifnum\numformat=-1
+\repeat
+
+\ifcase\numformat
+\or\def\stringtype{ordinalstring}
+\or\def\stringtype{Ordinalstring}
+\or\def\stringtype{ORDINALstring}
+\or\def\stringtype{numberstring}
+\or\def\stringtype{Numberstring}
+\or\def\stringtype{NUMBERstring}
+\fi
+
+\ifnum\langid>3\relax
+ \ifnum\langid<7\relax
+ \myctr=-1\relax
+ \loop
+ \typeout{Ordinal type?^^J}
+ \typeout{[1] eme}
+ \typeout{[2] e}
+ \typein[\response]{Default: 1}
+ \ifdefempty{\response}%
+ {%
+ \def\response{1}% default
+ \myctr=1\relax
+ }%
+ {%
+ \ifdefstring{\response}{1}%
+ {%
+ \fmtcountsetoptions{abbrv=false}\myctr=1\relax
+ }%
+ {%
+ \ifdefstring{\response}{2}%
+ {%
+ \fmtcountsetoptions{abbrv}\myctr=2\relax
+ }%
+ {%
+ \myctr=-1\relax
+ \typeout{Invalid response '\response', please select a
+number from 1 to 2}%
+ }%
+ }%
+ }%
+ \ifnum\myctr=-1
+ \repeat
+ \fi
+\fi
+
+\myctr=-1
+\loop
+ \typeout{Ordinal format?^^J}
+ \typeout{[1] raised}
+ \typeout{[2] level}
+ \typein[\response]{Default: 1}
+ \ifdefempty{\response}{\def\response{1}}{}%
+
+ \ifdefstring{\response}{1}
+ {%
+ \fmtcountsetoptions{fmtord=raise}\myctr=1\relax
+ }%
+ {%
+ \ifdefstring{\response}{2}
+ {%
+ \fmtcountsetoptions{fmtord=level}\myctr=2\relax
+ }%
+ {%
+ \myctr=-1\relax
+ \typeout{Invalid response '\response', please select a
+ number from 1 to 2}%
+ }%
+ }
+
+\ifnum\myctr=-1
+\repeat
+
+\ifnum\langid=1\relax
+ \myctr=1\relax
+\else
+
+ \ifboolexpr
+ {
+ test {\ifnumequal{\langid}{7}}
+ and
+ test {\ifnumgreater{\numformat}{3}}
+ }%
+ {%
+ \loop
+ \ifnum\langid=7\relax
+ \typein[\response]{Gender? (m, f or n) [Default: m]}
+ \ifcsundef{setgender\response}%
+ {%
+ \typeout{Invalid response '\response', please select a
+ number from 1 to 3}%
+ \myctr=-1\relax
+ }%
+ {\usegender\response}
+ \else
+ \typein[\response]{Gender? (m or f) [Default: m]}
+ \ifcsundef{setgender\response}%
+ {%
+ \typeout{Invalid response '\response', please select a
+ number from 1 to 2}%
+ \myctr=-1\relax
+ }%
+ {%
+ \ifdefstring{\response}{3}
+ {%
+ \typeout{Invalid response '\response', please select a
+ number from 1 to 2}%
+ \myctr=-1\relax
+ }
+ {%
+ \usegender\response
+ }
+ }
+ \fi
+ \ifnum\myctr=-1
+ \repeat
+ }%
+ {%
+ }
+
+\fi
+
+\ifcase\myctr
+\or \def\gender{m}
+\or \def\gender{f}
+\or \def\gender{n}
+\fi
+
+\ifnum\langid=7
+\ifnum\startval>99
+\myctr=-1
+\loop
+\typeout{einhundert/eintausend or hundert/tausend?^^J}
+\typeout{[1] einhundert/eintausend}
+\typeout{[2] hundert/tausend}
+\typein[\response]{Default: 1}
+\ifthenelse{\equal{\response}{}}{\def\response{1}}{}%default
+\ifthenelse{\equal{\response}{1}}{%
+\renewcommand{\einhundert}{einhundert}
+\renewcommand{\eintausend}{eintausend}
+\myctr=1}{%
+\ifthenelse{\equal{\response}{2}}{%
+\renewcommand{\einhundert}{hundert}
+\renewcommand{\eintausend}{tausend}
+\myctr=2}{%
+\myctr=-1}}
+\ifnum\myctr=-1
+\repeat
+\fi
+\fi
+
+\setcounter{startval}{\startval}
+\setcounter{endval}{\endval}
+\setcounter{stepsize}{\stepsize}
+
+\stepcounter{endval}
+\begin{ttfamily}
+\noindent
+\makebox[0.25in][c]{N}
+\makebox[0.5in][c]{ordinal}\quad
+\stringtype
+\par
+\myctr=\value{startval}
+\loop
+\noindent
+\setcounter{N}{\myctr}
+\makebox[0.25in][r]{\arabic{N}}
+\makebox[0.5in][r]{\ordinal{N}[\gender]}\quad
+\csname\stringtype\endcsname{N}[\gender].
+\par
+\advance\myctr by \value{stepsize}\relax
+\ifnum\myctr<\value{endval}
+\repeat
+
+\end{ttfamily}
+
+\end{document}