lua-users home
lua-l archive

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

Hello Bertrand,

I think the simplest way is to write some kind of preprocesor, for example:

local utf8 = require 'utf8'

local dict = {
  if = "если",
  then = "тогда",
  else = "иначе",
  elseif = "иначе_если",
  end = "закончить",
  function = "функция",

local to_russian = table.deepcopy(dict)
local from_russian = table.foreach(table.deepcopy(dict), function(t, k, v) t[v], t[k] = k, nil end)

local s = "%s"

for line in io.lines(arg[1]) do
  for keyword, repl in pairs(from_russian) do
    utf8.gsub( line, s .. '(' .. keyword .. ')' .. s, repl )

I hope idea is clear. Good luck!

btw, some time ago I've made pure-lua implementation of string library for utf8 charsequences

Best Regards, Alimov S.G.