Discussion:
iterating over all languages (was: \directlua in LaTeX3)
Stephan Hennig
2014-08-21 19:30:46 UTC
Permalink
I'm not sure this is what you are looking for, but in babel 3.9
{<exceptions-file>}.
That looks like a good start! Though, I can't find the string @elt in
the output of

\documentclass{article}
\usepackage[german]{babel}
\begin{document}
\makeatletter
\message{\***@languages}
\makeatother
\end{document}
[...]
I'll play with that. Thanks!

Best regards,
Stephan Hennig
Javier Bezos
2014-08-22 14:27:29 UTC
Permalink
Post by Stephan Hennig
the output of
\documentclass{article}
\usepackage[german]{babel}
\begin{document}
\makeatletter
\makeatother
\end{document}
Replace

\message{\***@languages}

by

\show\***@languages

to see the actual (unexpanded) contents of \***@languages. Or to see it
in action, try

\documentclass{article}
\usepackage[german]{babel}
\begin{document}
\makeatletter
\def\***@elt#1#2#3#4{// #1 - #2 - #3 - #4}
\message{\***@languages}
\makeatother
\end{document}

Javier
Stephan Hennig
2014-08-25 19:47:28 UTC
Permalink
Post by Stephan Hennig
\documentclass{article}
\usepackage[german]{babel}
\begin{document}
\makeatletter
\makeatother
\end{document}
Thanks! Here's what I've come up with to convert Babel language
identifiers to numbers in Lua.

Best regards,
Stephan Hennig


\documentclass{article}
\usepackage[german]{babel}
\begin{document}
\makeatletter
\begingroup
\def\***@elt#1#2#3#4{/#1/#2/#3/#4/}
\directlua{
% Global table translating language strings to numbers.
language_num = {}
local languages = '\luatexluaescapestring{\***@languages}'
for language, num, pattern, ex
in unicode.utf8.gmatch(languages, '/(.-)/(.-)/(.-)/(.-)/') do
language_num[language] = tonumber(num)
texio.write_nl(language .. ' = ' .. num)
end
}
\endgroup
\makeatother

\directlua{
local function lang2num(l)
local n = language_num[l] or 'unknown'
texio.write_nl('[lang2num] ' .. l .. ' = ' .. n)
end

lang2num('english')
lang2num('german')
lang2num('finish')
lang2num('finnish')
}
\end{document}

Loading...