lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Le 07/12/2015 18:55, Luiz Henrique de Figueiredo a écrit :
While wrapping standards libs with corresponding translation
shouldn't come with any technical difficulty, I would be interested
to know if anyone would have a better or more elegant solution.
Also, I'm not a Lua expert but it doesn't look like the language
provide any standard mechanism to rename/alias keywords. I would
warmly welcome any advice on this point.
See and that
while thread.

Thank you, very interesting thread, especially

I tried to transcribe it to esperanto and change it a bit, but the resulting code won't run (well the orginal code won't run ever):

local utf8 = require 'utf8'

local vortaro = {
  "if" = "se",
  "then" = "tiam",
  "else" = "alie",
  "elseif" = "alise",
  "end" = "fine",
  "function" = "funkcio",

local alesperanto = table.deepcopy(vortaro)
local elesperanto = table.foreach(table.deepcopy(vortaro), function(t, k, v) t[v], t[k] = k, nil end)

local cxeno = "%s"

for linio in io.lines(arg[1]) do
  for alirvorto, anstatauxo in pairs(elesperanto) do
    utf8.gsub( linio, sxeno .. '(' .. alirvorto .. ')' .. sxeno, anstatauxo )

I'm not yet fluent enough with Lua to understand what the code is suppose to do exactly. I find strange that alesperanto is declared but never used. If this would be a way to translate keywords without recompile the language, I would be very interesting in more explanation, documentation and so on.

I wish I may code my scribunto module in Wikimedia projects in plain esperanto, so a solution that require a change in the interpreter source code will be harder to obtain in production. But to play on my own desktop, it will already a great step, so thank Dirk Laurie and Luiz Henrique de Figueiredo who both pointed me to the llex.c solution.