Skip to content

Commit

Permalink
fix some translation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
FaceDeer committed Nov 16, 2020
1 parent 58b656f commit a5dbef7
Show file tree
Hide file tree
Showing 3 changed files with 509 additions and 24 deletions.
11 changes: 3 additions & 8 deletions bookgen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,17 @@ local S = settlements.S

-- values taken from default's craftitems.lua
local max_text_size = 10000
local max_title_size = 80
--local max_title_size = 80 -- truncating translated strings doesn't work well.
local short_title_size = 35
local lpp = 14

local generate_book = function(title, owner, text)
local book = ItemStack("default:book_written")
local meta = book:get_meta()

meta:set_string("title", title:sub(1, max_title_size))
meta:set_string("title", title)
meta:set_string("owner", owner)
local short_title = title
-- Don't bother trimming the title if the trailing dots would make it longer
if #short_title > short_title_size + 3 then
short_title = short_title:sub(1, short_title_size) .. "..."
end
meta:set_string("description", S("@1 by @2", short_title, owner))
meta:set_string("description", S("@1 by @2", title, owner))
text = text:sub(1, max_text_size)
text = text:gsub("\r\n", "\n"):gsub("\r", "\n")
meta:set_string("text", text)
Expand Down
Loading

0 comments on commit a5dbef7

Please sign in to comment.