Add string:trim8()
and fix intllib
This commit is contained in:
parent
eb535064ba
commit
e8ed7f95aa
@ -207,6 +207,10 @@ function string:trim()
|
|||||||
return (self:gsub("^%s*(.-)%s*$", "%1"))
|
return (self:gsub("^%s*(.-)%s*$", "%1"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function string:trim8()
|
||||||
|
return utf8.gsub(self, "^%s*(.-)%s*$", "%1")
|
||||||
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function math.hypot(x, y)
|
function math.hypot(x, y)
|
||||||
local t
|
local t
|
||||||
|
@ -20,7 +20,7 @@ local function parse_po(str)
|
|||||||
end
|
end
|
||||||
for _, line in ipairs(str:split("\n")) do repeat
|
for _, line in ipairs(str:split("\n")) do repeat
|
||||||
lineno = lineno + 1
|
lineno = lineno + 1
|
||||||
line = line:trim()
|
line = line:trim8()
|
||||||
|
|
||||||
if line == "" or line:match("^#") then
|
if line == "" or line:match("^#") then
|
||||||
state, msgid, msgid_plural = nil, nil, nil
|
state, msgid, msgid_plural = nil, nil, nil
|
||||||
|
@ -56,12 +56,12 @@ function intllib.load_strings(filename)
|
|||||||
end
|
end
|
||||||
local strings = {}
|
local strings = {}
|
||||||
for line in file:lines() do
|
for line in file:lines() do
|
||||||
line = line:trim()
|
line = line:trim8()
|
||||||
if line ~= "" and line:sub(1, 1) ~= "#" then
|
if line ~= "" and line:sub(1, 1) ~= "#" then
|
||||||
local pos = find_eq(line)
|
local pos = find_eq(line)
|
||||||
if pos then
|
if pos then
|
||||||
local msgid = unescape(line:sub(1, pos - 1):trim())
|
local msgid = unescape(line:sub(1, pos - 1):trim8())
|
||||||
strings[msgid] = unescape(line:sub(pos + 1):trim())
|
strings[msgid] = unescape(line:sub(pos + 1):trim8())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user