forked from enlightenment/efl
elua: initial stuff for the xgettext generator, check existence of all input files beforehand in the app, and other fixes
This commit is contained in:
parent
a98b916a74
commit
d8010702e8
|
@ -6,6 +6,8 @@ local util = require("util")
|
||||||
local cutil = require("cutil")
|
local cutil = require("cutil")
|
||||||
local getopt = require("getopt")
|
local getopt = require("getopt")
|
||||||
|
|
||||||
|
local generator = require("xgettext.generator")
|
||||||
|
|
||||||
local VERSION = "1.0.0"
|
local VERSION = "1.0.0"
|
||||||
|
|
||||||
local input_sources = {}
|
local input_sources = {}
|
||||||
|
@ -326,9 +328,7 @@ for i, v in ipairs(input_sources) do
|
||||||
local f = io.open(v)
|
local f = io.open(v)
|
||||||
if f then
|
if f then
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
if not line:lower():match("^.+%.lua$") then
|
input_files[#input_files + 1] = line
|
||||||
input_files[#input_files + 1] = line
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -344,12 +344,36 @@ args_nolua[#args_nolua + 1] = "--omit-header"
|
||||||
args_nolua[#args_nolua + 1] = "--output=-"
|
args_nolua[#args_nolua + 1] = "--output=-"
|
||||||
args_nolua[#args_nolua + 1] = false
|
args_nolua[#args_nolua + 1] = false
|
||||||
|
|
||||||
|
local found_files = {}
|
||||||
|
|
||||||
|
-- make sure all files exist first
|
||||||
|
for i, fname in ipairs(input_files) do
|
||||||
|
if fname ~= "-" and not excluded_files[fname] then
|
||||||
|
local ff = util.find_file(fname, search_dirs)
|
||||||
|
if not ff then
|
||||||
|
error(fname .. ": no such file or directory")
|
||||||
|
end
|
||||||
|
found_files[fname] = ff
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local parsed_files = {}
|
local parsed_files = {}
|
||||||
for i, fname in ipairs(input_files) do
|
for i, fname in ipairs(input_files) do
|
||||||
if not excluded_files[fname] then
|
if not excluded_files[fname] then
|
||||||
if onlylua or (not neverlua and fname:lower():match("^.+%.lua$")) then
|
if onlylua or (not neverlua and fname:lower():match("^.+%.lua$")) then
|
||||||
-- parse lua files here
|
-- parse lua files here
|
||||||
local fpath = util.find_file(fname, search_dirs)
|
local fcontents, fpath
|
||||||
|
-- handle stdin if needed
|
||||||
|
if fname == "-" then
|
||||||
|
fpath, fcontents = "=stdin", io.stdin:read("*all")
|
||||||
|
else
|
||||||
|
fpath = found_files[fname]
|
||||||
|
local f = io.open(fpath, "r")
|
||||||
|
fcontents = f:read("*all")
|
||||||
|
f:close()
|
||||||
|
end
|
||||||
|
parsed_files[#parsed_files + 1] = generator.init(fpath, fcontents,
|
||||||
|
keywords)
|
||||||
else
|
else
|
||||||
args_nolua[#args_nolua] = fname
|
args_nolua[#args_nolua] = fname
|
||||||
local f = assert(cutil.popenv(hasxgettext, "r",
|
local f = assert(cutil.popenv(hasxgettext, "r",
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- Elua xgettext: generator
|
||||||
|
|
||||||
|
local parser = require("xgettext.parser")
|
||||||
|
|
||||||
|
return { init = function(chunkname, input, keywords)
|
||||||
|
local ps = parser.init(chunkname, input, keywords)
|
||||||
|
end }
|
|
@ -134,4 +134,7 @@ end
|
||||||
return { init = function (chunkname, input, keywords)
|
return { init = function (chunkname, input, keywords)
|
||||||
local ls = lexer.init(chunkname, input)
|
local ls = lexer.init(chunkname, input)
|
||||||
ls:get()
|
ls:get()
|
||||||
|
local coro = coroutine.wrap(parse, ls, keywords)
|
||||||
|
coro(ls, keywords)
|
||||||
|
return coro
|
||||||
end }
|
end }
|
Loading…
Reference in New Issue