diff options
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/findtext.lua | 2 | ||||
| -rw-r--r-- | tools/updatetext.lua | 22 | 
2 files changed, 7 insertions, 17 deletions
diff --git a/tools/findtext.lua b/tools/findtext.lua index b6360cb..e5f6e88 100755 --- a/tools/findtext.lua +++ b/tools/findtext.lua @@ -123,7 +123,7 @@ table.sort(messages)  local last_msg -for i, msg in ipairs(messages) do +for _, msg in ipairs(messages) do  	if msg ~= last_msg then  		printf("%s =\n", escape(msg))  	end diff --git a/tools/updatetext.lua b/tools/updatetext.lua index 00f9bf6..5d5734b 100644 --- a/tools/updatetext.lua +++ b/tools/updatetext.lua @@ -7,7 +7,7 @@ end  if basedir == "" then basedir = "./" end  -- Required by load_strings() -function string.trim(s) +function string.trim(s) -- luacheck: ignore  	return s:gsub("^%s*(.-)%s*$", "%1")  end @@ -20,7 +20,7 @@ local function err(fmt, ...)  	os.exit(1)  end -local template +local output, outfile, template  local catalogs = { }  local function usage() @@ -54,10 +54,7 @@ while i <= #arg do  		if i > #arg then  			err("missing required argument to `%s'", a)  		end -	elseif (a == "-c") or (a == "--comment") then -		old_msg_mode = "c" -	elseif (a == "-d") or (a == "--delete") then -		old_msg_mode = "d" +		output = arg[i]  	elseif a:sub(1, 1) ~= "-" then  		if not template then  			template = a @@ -81,27 +78,18 @@ if not f then  	err("error opening template: %s", e)  end -local function printf(fmt, ...) -	outfile:write(fmt:format(...)) -end -  local escapes = { ["\n"] = "\\n", ["="] = "\\=", ["\\"] = "\\\\", }  local function escape(s)  	return s:gsub("[\\\n=]", escapes)  end  if output then -	local e  	outfile, e = io.open(output, "w")  	if not outfile then  		err("error opening file for writing: %s", e)  	end  end -local function printf(fmt, ...) -	io.stdout:write(fmt:format(...)) -end -  local template_msgs = intllib.load_strings(template)  for _, file in ipairs(catalogs) do @@ -120,10 +108,12 @@ for _, file in ipairs(catalogs) do  		for k, v in pairs(catalog_msgs) do  			if not template_msgs[k] then  				print("OLD: "..k) +				table.insert(dirty_lines, "OLD: "..escape(k).." = "..escape(v))  			end  		end  		if #dirty_lines > 0 then -			local outf, e = io.open(file, "a+") +			local outf +			outf, e = io.open(file, "a+")  			if outf then  				outf:write("\n")  				for _, line in ipairs(dirty_lines) do  | 
