local opts_final = {}
local opts_nolua = {}
+local add_loc = true
+
local opts, args = getopt.parse {
usage = "Usage: %prog [OPTION] [INPUTFILE]...",
args = arg,
.. "style", opts = opts_final
},
{ nil, "no-location", false, help = "do not write '#: filename:line' "
- .. "lines", opts = opts_nolua
+ .. "lines", opts = opts_nolua,
+ callback = function() add_loc = false end
},
{ "n", "add-location", false, help = "generate '#: filename:line' "
- .. "lines (default)", opts = opts_nolua
+ .. "lines (default)", opts = opts_nolua,
+ callback = function() add_loc = true end
},
{ nil, "strict", false, help = "write out strict Uniforum "
.. "conforming .po file", opts = opts_final
f:close()
end
parsed_files[#parsed_files + 1] = generator.init(fpath, fcontents,
- keywords, flags, opts)
+ keywords, flags, add_loc, opts)
else
args_nolua[#args_nolua] = fname
local f = assert(cutil.popenv(hasxgettext, "r",
return tconc(linestrs, "\n")
end
-return { init = function(chunkname, input, keywords, flags, opts)
+return { init = function(chunkname, input, keywords, flags, add_loc, opts)
local rets = {}
for i, msg in ipairs(gen_grouped_messages(parser.init(chunkname,
input, keywords, flags, opts))) do
if msg.context then
ret[#ret + 1] = "msgctxt " .. gen_message(msg.context)
end
- ret[#ret + 1] = gen_line_info(chunkname, msg.lines)
+ if add_loc then
+ ret[#ret + 1] = gen_line_info(chunkname, msg.lines)
+ end
ret[#ret + 1] = "msgid " .. gen_message(msg[1])
local spf, ssf = opts["m"], opts["M"]
if msg[2] then