I wish I had a tool to translate a module
Japualtah
Member Posts: 165
It's easy to translate a tlk file, but strings scattered all around scripts, dialogs and areas are a pain.
Does such a tool exist?
Does such a tool exist?
0
Comments
Or are you translating someone else’s work where they didn’t do that?
If we had a tool to extract all strings (mostly from dialog/areas though, scripts are cumbersome but manageable) into a single file, translation would be a breeze.
Now, my 15 years old PW is in French, I recently began using tlks for every script and going through the menus hassle but soon forgot about it: way too time consuming and inefficient.
https://github.com/niv/neverwinter_utils.nim/blob/master/src/nwn_erf_tlkify.nim
tl;dr:
* Create your module as usual.
* Pipe it into the tool: ./tlkify mytlk.tlk mymod.mod mymodrewritten.mod
* The tool will find all new strings and rewrite them into STRREFs, adding them to the tlk.
* Thus, the generated TLK will be authoritative and the rewritten module depend on it.
* The rewritten module will be written to mymodrewritten. You don't have to continue your work on the rewritten one; as the process is repeatable.
* In fact, I suggest to only do a translation effort once you are done and keep the non-translated mod as the authoritative source.
* Repeat as needed as you go through the release cycles.
Caveats:
* You can rewrite any erf container - if you bundle templates in haks, for example - but I haven't tested that.
* It might miss some strings. (I did say it was untested, right?)
* It might add strings to the translation table that don't need translation ("Tree 48b", I'm looking at you).
Edit: Binaries are here: https://github.com/niv/neverwinter_utils.nim/releases
Would appreciate feedback! Happy to fix up any issues you find.
Going to check this out as soon as my website porting to WordPress is done, this looks fantastic
But now I know for what that tool is
Downloaded your binaries, put an empty .tlk file and module in the same folder as nwn_erf_tlkify, launched nwn_erf_tlkify with, as parameters, the empty tlk, the module and a choosen name for the output and I got an output once (a stripped down module) with an unchanged tlk.
It never worked after that, command line progamming isn't my thing I must say.
Oh well...
> ./nwn_erf_tlkify.exe mytlk.tlk mymod.mod out.mod
I [2018-10-16T21:04:50] Base TLK name: mytlk
I [2018-10-16T21:04:50] Translations: starting from scratch
I [2018-10-16T21:04:50] Reading: mymod.mod
Error: unhandled exception: len(exolocstr.entries) == 1 exolocstring has multiple languages, but we can only do one language [AssertionError]
Would it be possible to add a parameter to choose the primary language to translate from and discard any other resource the analysis stumbles across?
I got only one warning with nwn_erf_tlkifiy: Error: unhandled exception: getPosition(io) == entriesTableOffset + entriesTableSize [AssertionError]... But the converted tlk seems fine.
+ for an opt to choose the language to translate
The assert triggers AFTER writing the tlk (so it would have been written), indicating a possible error. Likely a encoding/charset issue. Some special character that transformed into a different byte width than expected.
Edit: Can you share the module that's failing? Would love to look at/possibly fix.
Yes it wrote the tlk file flawlessly, didn't spell checked it yet. I wanted to test it first with one english mod, so I can get used to it.
The module I shamelessly used for testing was this one, because mine use only german.
https://neverwintervault.org/project/nwn1/module/mortari-riseth-module
I [2019-02-16T13:36:07] Base TLK name: althea
I [2019-02-16T13:36:07] Building translations from given tlk: 629
I [2019-02-16T13:36:07] Reading: althea.mod
Error: unhandled exception: /Users/niv/code/neverwinter.nim/nwn_erf_tlkify.nim(95, 17) `hasKey(exolocstr.entries, int(selectedLanguage)) and
1 < len(exolocstr.entries)` exolocstring has other language strings but not the selected language [AssertionError]
I guess this means I have text resources with French strings while the English resource is empty.
Could it be possible to just put the unexpected string into the expected but empty string please?
My shell skills have been rusty for over 20 years otherwise I'd do it myself, but I really need your help here, I'm now in the process of translating the mod.
Thanks for your continuous efforts mate, much appreciated ;-)
Here is the module in .zip format
I don't quite see where the problem is though, the first item in your list is a creature blueprint (1_cleric) and besides the name (which only exists in English) I can't see any other translation mismatch possibility.
Whatever, it's not important, I'm very happy with your support and will wait for the binaries, all is fine ;-)
./nwn_erf_tlkify.exe --languages 0,1 --root 'C:\Program Files (x86)\Steam\steamapps\common\Neverwinter Nights' althea.tlk althea.mod a2.mod
I [2019-02-20T10:39:50] Base TLK name: althea
I [2019-02-20T10:39:50] Selected languages: @[English, French]
I [2019-02-20T10:39:50] Base game dialog TLK at: C:\Program Files (x86)\Steam\steamapps\common\Neverwinter Nights/data/dialog.tlk
I [2019-02-20T10:39:50] Building translations from given tlk: 83
I [2019-02-20T10:39:50] Reading: althea.mod
Error: unhandled exception: /Users/niv/code/neverwinter.nim/nwn_erf_tlkify.nim(119, 15) `isSome(foundLanguage)` none of your selected languages satisfy string: [4294967295]{2: "Syrthe, Office du recrutement, 1er Útage"} [AssertionError]
I tried toying with --nwn-encoding CHARSET trying UTF-8 and ANSI (unknown) but it seems the word "étage" is the problem and gets transformed into "Útage", I can't go any further.
My original files are still available if needed.
Please note all my scripts in the new module a2.mod contain "MOD V1.0" in place of any code, which I guess is because the process didn't go to the end, since the areas can not be opened either and have their name changed with their tag.
Thanks again for you support, I can finally see the light at the end of the tunnel ;-)
2 Is German. You're only adopting languages 0 and 1. See languages.nim here: https://github.com/niv/neverwinter.nim/blob/master/neverwinter/languages.nim
Language* {.pure.} = enum
English = 0
French = 1
German = 2
reason why I typed ./nwn_erf_tlkify.exe --languages 0,1
*confused*
There's no German fork in the aforementioned resource, both English and French contain the same string "Syrthe, Office du recrutement, 1er étage".
*wanders around in utter confusion*
As you can tell from the picture, I'm happy!
You're the man Niv, consider yourself hugged!
Now a last question if I may: all my text resources now appear on a yellow background which means they come from my .tlk file.
Is it possible when, for example, creating a new zone, to have the zone Name directly pointing towards the .tlk like your tool did?
Cheers!