mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[i18n] GetText: ignore fuzzy strings (#5807)
Strings are prefilled by msgmerge with closely matching ones to reduce the amount of labor required by the translator. Often the string requires only minor adjustment, making the process faster, and when the string isn't a good match it's no big deal. However, these so-called fuzzy strings shouldn't be treated as if they were actually translated. Fixes the effect seen in <https://github.com/koreader/koreader/issues/5806>.
This commit is contained in:
@@ -188,6 +188,7 @@ function GetText_mt.__index.changeLang(new_lang)
|
||||
end
|
||||
|
||||
local data = {}
|
||||
local fuzzy = false
|
||||
local headers
|
||||
local what = nil
|
||||
while true do
|
||||
@@ -257,13 +258,18 @@ function GetText_mt.__index.changeLang(new_lang)
|
||||
-- string continuation
|
||||
s = line:match("^%s*\"(.*)\"%s*$")
|
||||
end
|
||||
if what and s then
|
||||
if what and s and not fuzzy then
|
||||
-- unescape \n or msgid won't match
|
||||
s = s:gsub("\\n", "\n")
|
||||
-- unescape " or msgid won't match
|
||||
s = s:gsub('\\"', '"')
|
||||
data[what] = (data[what] or "") .. s
|
||||
else
|
||||
-- Don't save this fuzzy string and unset fuzzy for the next one.
|
||||
fuzzy = false
|
||||
end
|
||||
elseif line:match("#, fuzzy") then
|
||||
fuzzy = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user