Add `string:trim8()` and fix intllib

master
MoNTE48 2022-01-21 15:10:58 +01:00
parent eb535064ba
commit e8ed7f95aa
3 changed files with 8 additions and 4 deletions

View File

@ -207,6 +207,10 @@ function string:trim()
return (self:gsub("^%s*(.-)%s*$", "%1"))
end
function string:trim8()
return utf8.gsub(self, "^%s*(.-)%s*$", "%1")
end
--------------------------------------------------------------------------------
function math.hypot(x, y)
local t

View File

@ -20,7 +20,7 @@ local function parse_po(str)
end
for _, line in ipairs(str:split("\n")) do repeat
lineno = lineno + 1
line = line:trim()
line = line:trim8()
if line == "" or line:match("^#") then
state, msgid, msgid_plural = nil, nil, nil

View File

@ -56,12 +56,12 @@ function intllib.load_strings(filename)
end
local strings = {}
for line in file:lines() do
line = line:trim()
line = line:trim8()
if line ~= "" and line:sub(1, 1) ~= "#" then
local pos = find_eq(line)
if pos then
local msgid = unescape(line:sub(1, pos - 1):trim())
strings[msgid] = unescape(line:sub(pos + 1):trim())
local msgid = unescape(line:sub(1, pos - 1):trim8())
strings[msgid] = unescape(line:sub(pos + 1):trim8())
end
end
end