other languages

This commit is contained in:
Marc Beninca 2020-10-08 21:07:48 +02:00
parent 59574d623b
commit 1538172cae
3 changed files with 19 additions and 8 deletions

View file

@ -30,8 +30,17 @@ def build(directory, sign):
tmp = os.path.join(directory, TMP)
# for each language
for language in LANGUAGES:
# other languages
other_languages = ','.join(
[lang for lang in LANGUAGES if lang is not language])
# display languages
print()
print(language, other_languages)
# for each document
for document in DOCUMENTS:
# display language
print()
print(document[language])
# clean
os.chdir(directory)
wipe(tmp)
@ -39,8 +48,10 @@ def build(directory, sign):
# move into document directory
os.chdir(document[ENGLISH])
# prepare variables
variables = {'mainlanguage': language,
}
variables = {
'mainlanguage': language,
'otherlanguages': other_languages,
}
# transform variables
variables = ''.join([f'\\def\\{k}{{{v}}}'
for k, v in variables.items()])

View file

@ -4,13 +4,13 @@
% begin document
\begin{document}
\bi{}{}
\ml{}{}
\bi{Hello world!}{}
\ml{Hello world!}{}
\bi{}{Bonjour monde !}
\ml{}{Bonjour monde !}
\bi{Hello world!}{Bonjour monde !}
\ml{Hello world!}{Bonjour monde !}
% end document
\end{document}

View file

@ -6,12 +6,12 @@
% set languages
\setmainlanguage{\mainlanguage}
\setotherlanguages{en,fr}
\setotherlanguages{\otherlanguages}
% language commands
\newcommand{\ifstr}[4]{\expandafter\ifstrequal\expandafter{#1}{#2}{#3}{#4}}
\newcommand{\bi}[2]{%
\newcommand{\ml}[2]{%
\ifstr{\mainlanguage}{en}{\ifstrempty{#1}{TRANSLATE\_ME!}{#1}}{%
\ifstr{\mainlanguage}{fr}{\ifstrempty{#2}{TRADUISEZ\_MOI\_!}{#2}}{%
SHOULD\_NOT\_HAPPEN!%