[lltx] convert language name to number in Lua

Stephan Hennig mailing_list at arcor.de
Tue Feb 11 23:54:53 CET 2014


Hi,

consider the following macro \langnum, which stores the language number
corresponding to an arbitrary language name in a Lua variable

  \documentclass{article}
  \usepackage[UKenglish]{babel}
  \newcommand*{\langnum}[1]{%
    \directlua{
      local number = \the\csname l@#1\endcsname
      tex.print(number)
    }
  }
  \begin{document}
  \langnum{USenglish} \langnum{UKenglish}
  \end{document}

How would I do the same conversion of a name to a number in pure Lua,
given a string containing an arbitrary language name?

Best regards,
Stephan Hennig


More information about the lualatex-dev mailing list