Mon, 25 Aug 2014 21:47:28 +0200
|
Am 22.08.2014 um 16:27 schrieb Javier Bezos:
> \documentclass{article}
> \usepackage[german]{babel}
> \begin{document}
> \makeatletter
> \def\bbl@elt#1#2#3#4{// #1 - #2 - #3 - #4}
> \message{\bbl@languages}
> \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\bbl@elt#1#2#3#4{/#1/#2/#3/#4/}
\directlua{
% Global table translating language strings to numbers.
language_num = {}
local languages = '\luatexluaescapestring{\bbl@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}
|
|
|