% Written by Martin Mares <mj@ucw.cz> in 2010--2018 and placed into public domain
% -------------------------------------------------------------------------------
+\ifx\ucwmodule\undefined\else\endinput\fi
+
%%% Prolog %%%
% We'll use internal macros of plain TeX
%%% Auxiliary macros %%%
-% Append #2 to the definition of #1
-\long\def\addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
+% Prepend/append #2 to the definition of #1
+\long\def\prependef#1#2{\expandafter\def\expandafter#1\expandafter{#2#1}}
+\long\def\appendef#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
+
+\def\ucwwarn#1{\immediate\write16{*** Warning: #1 ***}}
%%% Page size and margins %%%
\let\plaintilde=~
\protected\def~{\plaintilde}
+%%% Localization %%%
+
+% Current language
+\def\localelang{en}
+
+% Define a new localized string: \localedef{language}{identifier}{message}
+\def\localedef#1#2{\expandafter\def\csname loc:#1:#2\endcsname}
+
+% Expand a localized string in the current language: \localemsg{identifier}
+\def\localestr#1{%
+ \ifcsname loc:\localelang:#1\endcsname
+ \csname loc:\localelang:#1\endcsname
+ \else
+ \ucwwarn{Localized string #1 not defined in language \localelang}%
+ ???%
+ \fi
+}
+
+%%% Modules %%%
+
+\def\ucwmodule#1{
+ \ifcsname ucwmod:#1\endcsname
+ \else
+ \input ucw-#1.tex
+ \fi
+}
+
+\def\ucwdefmodule#1{
+ \ifcsname ucwmod:#1\endcsname\endinput\fi
+ \expandafter\let\csname ucwmod:#1\endcsname=\relax
+}
+
%%% Epilog %%%
% Let's hide all internal macros