How to convert translation file from old .rpt to new format?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
User avatar
uyjulian
Regular
Posts: 128
Joined: Sun Mar 08, 2015 1:40 pm
Github: uyjulian
Contact:

How to convert translation file from old .rpt to new format?

#1 Post by uyjulian » Sun Mar 08, 2015 1:42 pm

How to I convert translation file from old .rpt to new format?

User avatar
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

#2 Post by PyTom » Sun Mar 08, 2015 4:14 pm

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
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
uyjulian
Regular
Posts: 128
Joined: Sun Mar 08, 2015 1:40 pm
Github: uyjulian
Contact:

Re: How to convert translation file from old .rpt to new for

#3 Post by uyjulian » Sun Mar 08, 2015 4:45 pm

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)

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

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Sergei Falcon, zyric