% define variables ─────────────────────────────────────────────────────────────

\def\todo{TODO}

% author
\def\authorname{BENINCA}
\def\authorshort{M. \authorname}
\def\authorlong{Marc \authorname}

% date
\def\dateshort{2021}
\def\datelong{\ml{Month DD, \dateshort}{JJ Mois \dateshort}}

% institute
\def\instituteshort{CNAM}
\def\institutelong{Conservatoire National des Arts et Métiers}

% manage languages ─────────────────────────────────────────────────────────────

% use package
\usepackage{polyglossia}
% use recommended package
\usepackage{csquotes}

% set main
\setmainlanguage{\mainlanguage}
% set others
\setotherlanguages{\otherlanguages}

% expand function ifstrequal
\newcommand{\ifstreq}[4]{\expandafter\ifstrequal\expandafter{#1}{#2}{#3}{#4}}
% return text, according to variable mainlanguage
% 1: english text
% 2: french text
\newcommand{\ml}[2]{%
\ifstreq{\mainlanguage}{english}{\ifstrempty{#1}{\todo}{#1}}{%
\ifstreq{\mainlanguage}{french}{\ifstrempty{#2}{\todo}{#2}}{%
ERROR%
}}%
}

% return text as english
% 1: text
\newcommand{\en}[1]{\textenglish{#1}}

% return text as french
% 1: text
\newcommand{\fr}[1]{\textfrench{#1}}

% define multilingual variables ────────────────────────────────────────────────

% title
\def\titleshort{\ml{Incremental Live OS}{SE autonomes incrémentaux}}
\ml
{\def\titlelong{Incremental Live Operating Systems}
\def\titlesub{a reversal of conventional approaches}}
{\def\titlelong{Systèmes d’Exploitation autonomes incrémentaux}
\def\titlesub{une inversion des approches conventionnelles}}

% type
\ml
{\def\typeshort{Thesis}}
{\def\typeshort{Mémoire}}
\ml
{\def\typelong{\instituteshort\ Master's \typeshort}}
{\def\typelong{\typeshort\ d’Ingénieur \instituteshort}}

% key words (part a)
\def\kwaen{one, two, three, four}
\def\kwafr{un, deux, trois, quatre}

% key words (part b)
\def\kwben{five, six, seven, eight}
\def\kwbfr{cinq, six, sept, huit}

% return key words (part a)
% 1: language
\newcommand{\kwa}[1]{%
\ifstreq{#1}{english}{\kwaen}{}%
\ifstreq{#1}{french}{\kwafr}{}%
}
% return key words (part b)
% 1: language
\newcommand{\kwb}[1]{%
\ifstreq{#1}{english}{\kwben}{}%
\ifstreq{#1}{french}{\kwbfr}{}%
}

% final variable kw
\ml
{\def\kw{\kwaen, \kwben}}
{\def\kw{\kwafr, \kwbfr}}

% set links and pdf metadata ───────────────────────────────────────────────────

\usepackage{hyperref}
\hypersetup{
pdfinfo={
Subject={\typelong},
Keywords={\kw},
},
}

% import from subdirectories ───────────────────────────────────────────────────

\usepackage{import}

% include settings ─────────────────────────────────────────────────────────────

\input{settings}

% begin document ───────────────────────────────────────────────────────────────

\begin{document}
