Author Topic: Translation tools; replacing strings in scripts files  (Read 1337 times)

0 Members and 1 Guest are viewing this topic.

Offline ZvikaZ

Translation tools; replacing strings in scripts files
« on: July 19, 2020, 10:16:15 AM »
Hi.

2 related questions:

1.
What tools exist for translating games, from early SCI, such as SQ3?
I've seen http://sci.sierrahelp.com/Tools/TraduSCI.html, but it's for later games.
Are there any more relevant tools?

2.
I've built Python scripts to extract all information from the 'text' files to a CSV, and build 'text' files from the CSVs.
I've also built Python scripts to extract all words from the vocabulary to a CSV, and build back the vocab.
Now my problem is the strings inside the scripts files.
I've built Python script that extracts all text strings from the (decompiled) scripts files to a CSV file.
However, building back (compiled) scripts files from the CSV file is more problematic:

- My first thought was to go over the binary script file (patch extracted from SCICompanion), analyze it, replace the strings in the strings area, and then fix the offsets.
But then I realized that there is also information after the strings area, and therefore I will need to fix its offsets as well.
Sounds cumbersome...

- My second thought was to try to replace all string code hard-coded in the scripts file, to something that will tell it to use strings from texts files, and add the relevant strings to the texts files.
Is it feasible, or am I missing something here?

- My next thought was that probably someone has done part of this job already, so I came to ask here...
I've been told that there are quite old SCI fan-made translations (such as to Polish), that were made by non-programmers, so there's probably some nice tool that they used. But I haven't found any such as nice tool.

Thanks





Offline Kawa

Re: Translation tools; replacing strings in scripts files
« Reply #1 on: July 19, 2020, 12:19:54 PM »
What you haven't said is why compiling edited SC files is "problematic". You just said it was, no further elaboration, and went on to consider hacking the raw script resources which by all means ought to be harder than editing plaintext .sc files.

Why then can you not compile edited .sc files? How is it "more problematic"?

Offline ZvikaZ

Re: Translation tools; replacing strings in scripts files
« Reply #2 on: July 19, 2020, 02:41:59 PM »
What you haven't said is why compiling edited SC files is "problematic". You just said it was, no further elaboration, and went on to consider hacking the raw script resources which by all means ought to be harder than editing plaintext .sc files.

Why then can you not compile edited .sc files? How is it "more problematic"?

You're right that I haven't elaborated why haven't tried compiling edited SC files.
However, when I said that "it's problematic" I meant other thing - I meant taking my CSV file with all the strings, and modiy the raw script resources.
And I did elaborate why I think that "it's problematic" - the two points below.

Never mind, we both agree that this approach is complicated...

Regarding compiling the edited .sc files - well, I indeed thought that it won't work.
However, since you've suggested it, I'm trying it again.

I opened up SCICompanion, with a fresh SQ3.
Though to make minimal changes, just to check.
So, decompiled a single file (Main.sc - since I want to modify the inventory).
Made a small change - changed 'Glowing_Gem' description - added a word (not even in Hebrew...) in the beginning.
Then clicked Script->Compile, and got many errors :-(

So, maybe I should decompile everything, because everything might depend on everything?
Done that.

Now I'm getting only two errors:

Quote
Unable to load \.
Error: (Main.sc) Unknown class 'gamefile_sh' .  Line: 779, col: 9
Warning: (Main.sc) Instance 'logFile' is not used anywhere.  Line: 779, col: 9
Any idea?

EDIT
===
I've moved back to Phil's SCICompanion, and now there is only one error:
Quote
  [Error]: Unknown class 'gamefile_sh' .  Line: 779, col: 9

Still, any advice?

Thanks
« Last Edit: July 19, 2020, 02:53:33 PM by ZvikaZ »

Online lskovlun

Re: Translation tools; replacing strings in scripts files
« Reply #3 on: July 19, 2020, 03:04:26 PM »
gamefile_sh is a class name, but it's an odd one because to use it, you must set the name property, which changes the class name. And filenames contain periods, which SCI Companion converts into underscores in most cases. And here we have a bug (from Main.sc):
Code: [Select]
(use gamefile.sh)
with a period. My version of Companion simply says "Unknown class gamefile_sh. Did you forget to use 'gamefile'?'
Anyway, the whole exercise is pointless in this case because logFile turns out to be unused so it can simply be removed. I'm documenting it because the same problem could turn up elsewhere.

Offline ZvikaZ

Re: Translation tools; replacing strings in scripts files
« Reply #4 on: July 19, 2020, 03:16:23 PM »
gamefile_sh is a class name, but it's an odd one because to use it, you must set the name property, which changes the class name. And filenames contain periods, which SCI Companion converts into underscores in most cases. And here we have a bug (from Main.sc):
Code: [Select]
(use gamefile.sh)
with a period. My version of Companion simply says "Unknown class gamefile_sh. Did you forget to use 'gamefile'?'
Anyway, the whole exercise is pointless in this case because logFile turns out to be unused so it can simply be removed. I'm documenting it because the same problem could turn up elsewhere.

Thanks for the explanation.
Indeed, simply removing this code solves the problem, and as you said - probably doesn't matter.

Still, @kawa, if you could look at that bug, and fix it - it'd be great.

Another question - which, again @kawa, is one of the reasons I prefered not to use SCICompanion - I wanted it to be done in batch.
Is there a way to run compilation, and then export to patch, from command line? (like Unix 'gcc' ...)
Or if it's not possible now, any chance that it'd be added?

And another question - I want to translate to Hebrew, and it's indeed working.
However, in SCICompanion it's shown like Gybrish - using the wrong page encoding.
Is there a possibility to change the encoding?
(or again, maybe it could be added in the future?)

Thanks for all the help.

Offline Kawa

Re: Translation tools; replacing strings in scripts files
« Reply #5 on: July 19, 2020, 04:48:38 PM »
It's spelled "gibberish". Best idea I have to offer is to not edit the script files in SCI Companion, only blindly compile them. So long as the editor you do use has the right encoding in mind, it might Just Work then.

Aaaaand no, I wouldn't know where to begin adding command line controls. Parsing out the arguments, sure, I literally just learned where and how that's done (because MFC does things its own way), but actually acting on them? Preferably without showing the main window, or even taking all the time and effort to load it? No can do.
« Last Edit: July 19, 2020, 04:50:13 PM by Kawa »

Offline Daventry


Offline ZvikaZ

Re: Translation tools; replacing strings in scripts files
« Reply #7 on: July 20, 2020, 10:27:00 AM »
ZvikaZ
Try this
https://github.com/deadman2000/sci_translator

Thanks. Are you familiar with this tool?
You know, it's in Russian, not documented enough and without executable.
I read it a little with Google Translate, and it seems interesting, however, I'm not sure that it's worth investing time, unless someone will recommend it.

Offline ZvikaZ

Re: Translation tools; replacing strings in scripts files
« Reply #8 on: July 20, 2020, 10:27:57 AM »
It's spelled "gibberish". Best idea I have to offer is to not edit the script files in SCI Companion, only blindly compile them. So long as the editor you do use has the right encoding in mind, it might Just Work then.

Aaaaand no, I wouldn't know where to begin adding command line controls. Parsing out the arguments, sure, I literally just learned where and how that's done (because MFC does things its own way), but actually acting on them? Preferably without showing the main window, or even taking all the time and effort to load it? No can do.
Well, yeah, it's indeed working.

Offline ZvikaZ

Re: Translation tools; replacing strings in scripts files
« Reply #9 on: July 20, 2020, 10:32:02 AM »
Just stumbled upon other problem - recompiling Main.sc (even without changing anything) makes a different file, and therefore the game crashes quite quickly.
I assume I need to recompile all files; and then export all scripts patches.
It's possible; however, I hoped to make it "small and tidy" set of patches, now I need to supply all games' scripts, even if they aren't changed.

EDIT
====
I tried again recent Kawa's build - and it's working great. I can compile just Main.sc, without recompiling other files (at least, so far...)

So, if I change inventory strings in Main.sc - does it make sense that I don't need to recompile other files, or at some point in the future I will realize that I *do* need to do that?
I got a little bit confused...
« Last Edit: July 20, 2020, 10:48:13 AM by ZvikaZ »

Offline Collector

Re: Translation tools; replacing strings in scripts files
« Reply #10 on: July 20, 2020, 10:52:50 AM »
Looks like it is using Companion's SCI SCI library. Out of curiosity, what is Companion's license?
KQII Remake Pic

Offline Kawa

Re: Translation tools; replacing strings in scripts files
« Reply #11 on: July 21, 2020, 05:19:16 AM »
GPL, it seems, from looking at the blurb at the top of a random .cpp file.

Offline Daventry

Re: Translation tools; replacing strings in scripts files
« Reply #12 on: July 21, 2020, 11:54:10 AM »
ZvikaZ
Here is the compiled version. The program is not finished, but it was used to translate the game Conquest of the Longbow.

Offline ZvikaZ

Re: Translation tools; replacing strings in scripts files
« Reply #13 on: July 21, 2020, 12:08:55 PM »
ZvikaZ
Here is the compiled version. The program is not finished, but it was used to translate the game Conquest of the Longbow.

Thanks!
However, I think I have built good enough workflow and toolset:
- bunch of Python scripts that export all strings to few csv files (vocab, texts, and scripts' strings)
- uploaded all of them to Google Drive
- volunteers already working on translating it over there
- manually downloading back csv files from Google Drive
- bunch of Python scripts import all strings back to Sierra format, and create zip file with everything

It's working very well, and allow easy sharing of the translation work over the net.
I might improve it by automating the csv -> google -> csv flow; but it's technical, and not related to this forum...
There's also the manual point of compiling the modified scripts in SCICompanion (as it doesn't have CLI) - but I can live with this.

Therefore, since I've solved all the problems I've encountered so far, I don't think I need now to change the workflow.

Thanks for everyone in this forum for the help in this project :-)
« Last Edit: July 21, 2020, 12:17:52 PM by ZvikaZ »


SMF 2.0.14 | SMF © 2017, Simple Machines
Simple Audio Video Embedder

Page created in 0.132 seconds with 23 queries.