LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Stephan Hennig <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Mon, 25 Aug 2014 21:47:28 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (50 lines)
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}

ATOM RSS1 RSS2