How to convert translation file from old .rpt to new format?
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
How to convert translation file from old .rpt to new format?
How to I convert translation file from old .rpt to new format?
- PyTom
- Ren'Py Creator
- Posts: 15893
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: How to convert translation file from old .rpt to new for
Unfortunately, there isn't a straightforward way to do this.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom
Re: How to convert translation file from old .rpt to new for
Okay, so I looked at the renpy tutorial game, and this gave me some hints.
Here's an lua script to convert it automatically. (note: you may need to make some changes yourself)
Here's an lua script to convert it automatically. (note: you may need to make some changes yourself)
Code: Select all
local file = io.open(arg[1])
local oldtrans = nil
local translatearray = {}
for line in file:lines() do
local firstchar = line:sub(1,1)
if firstchar ~= "#" then --don't merge comments
if firstchar == "<" then -- from file
if oldtrans ~= nil then
error("from file twice")
end
for i, v in pairs(translatearray) do
if v[1] == line then
error("string twice")
end
end
oldtrans = line
elseif firstchar == ">" then -- to file
if oldtrans == nil then
error("no translation")
end
table.insert(translatearray, {oldtrans:sub(3), line:sub(3)})
oldtrans = nil
end
end
end
function requote(str)
local form = "%q"
return form:format(str)
end
for i, v in pairs(translatearray) do
io.stdout:write(" " .. "old " .. requote(v[1]) .. "\n" )
io.stdout:write(" " .. "new " .. requote(v[2]) .. "\n" )
end
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], Sergei Falcon, zyric