PDA

View Full Version : Updating the stringtables after a patch



TokPhobia
08-14-2009, 09:07 AM
Hello everyone!

As most of the people working on translations have probably noticed, patches sometimes change the stringtables by adding or removing lines. This means that you need to check (by hand or by using tools) which lines have been changed and modify your translated stringtables.

To help with this, I've whipped up a small Python script that does the job. The source code is attached to this post.

To use it, copy the new english stringtables and your old translated stringtables in the same directory as the script. Then, in your Python console type:


import updater
updateTables("ro")Of course you should replace "ro" with whatever language you're translating to ( in this case I used Romanian ). The script will create four new ( hopefully ) corrected stringtable files.

The script isn't very complex. It just takes each line from the english version and extracts its variable name. It then checks the translated version for a line with the same variable name. If it finds it, it copies the line from the translated version. If it doesn't find it, then the line is new so it copies it from the english version. Lines from the translated version that have been deleted in the patch are never copied.

Disclaimer: The script still needs more testing ( on more files than just mine ) so it might not work as expected. Also, you should backup your files before using it, just in case. Finally, use it at your own risk ( I won't be responsible if the computer turns into a fireball or any other damage it might cause ).

Hope you guys find it useful and I await your feedback!

tomas666
08-24-2009, 02:42 PM
when i try to use your script, i get following error:

Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
updateTables("cz")
File "C:\Users\Tomas\Downloads\updater\updater.py", line 8, in updateTables
untranslated = open(current_file+"_en.str", "rb").read().split("\n")
TypeError: Type str doesn't support the buffer API

and i also had to delete all the "print" functions, because it kept saying something about wrong syntax

i think your script will be very useful, so plz fix this. i dont want to code a new programm in delphi...

Magissia
08-24-2009, 03:41 PM
I have an "Invalid Syntax" error with Python 3.1.1

tomas666
08-24-2009, 04:50 PM
I have an "Invalid Syntax" error with Python 3.1.1
delete all "print" functions, it will solve your problem. however, i think you won't succeed because of the problem i have described one post above yours.

Magissia
08-24-2009, 05:17 PM
Removing the lines

print "Added %d lines to %d existing lines (out of which %d are empty)" % (count_added, count_existing + count_empty, count_empty)
print "Processing complete."

change nothing, i get a Syntax Error

tomas666
08-25-2009, 01:53 AM
Removing the lines

print "Added %d lines to %d existing lines (out of which %d are empty)" % (count_added, count_existing + count_empty, count_empty)
print "Processing complete."

change nothing, i get a Syntax Error

there is one more print function in the beggining, like Processing... x%

Magissia
08-25-2009, 06:49 AM
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
updateTables("fr")
File "D:\Python31\updater\updater.py", line 8, in updateTables
untranslated = open(current_file+"_en.str", "rb").read().split("\n")
TypeError: Type str doesn't support the buffer API