tModLoader ModLocalizer - A tool to create localization for tModLoader mods

mistzzt

Terrarian
Mod localizer is a tool developed for players to create their own localized mod easily; it support mods of tModLoader v0.10 or higher version.

Introduction
As far as we know, tModLoader has added a new feature enabling mod to have its translations. However, it cannot be easily used since it needs you to know how to code and it only works with open-source mod.

But this tool solves these problems of tModLoader's internationalization feature:

  • It can read .tmod files and generate game content (like item names, tooltips and buff descriptions) in JSON format in which format you can translate them into your language with comfort.

  • After your translating, the tool will use your translation to modify contents inside .tmod files regardless whether it is open source by changing and emitting IL codes in DLLs.

  • It doesn't require programming knowledges; all you have to know is how to use command line and edit files using editors like VSCode.
Usage
ModLocalizer --mode dump <Mod Name>
Example: ModLocalizer --mode dump ExampleMod.tmod

Program will create a new folder which name is the same as that of mod file and output mod contents inside it.

ModLocalizer --mode patch --folder <content path> --language <language> [Mod file]
Example: ModLocalizer --mode patch --folder ExampleModContent --language Chinese ExampleMod.tmod

Modify ExampleMod.tmod according to contents in ExampleModContent folder.

The folder option is mandatory when the program mode is patch, because program needs it to modify mod file.

You have seven languages for chosing:

  • English
  • German
  • Italian
  • French
  • Spanish
  • Russian
  • Chinese (This is default language if you don't specify one using --language)
  • Portuguese
  • Polish
They're case-sensitive: you must enter them as what exactly they are here (also without spaces).

If I chose Chinese, then my translations will only show when I use Chinese language in Terraria Settings. So you must carefully choose your language to let your translations work.

After executing, program will generate a file ends with _patched.tmod in your current directory.

For further usage, enter ModLocalizer --help.

How to translate mod content
You might get something like this when translating mod:

Code:
{
"TypeName": "DO-NOT-EDIT-ME", // DO NOT EDIT THIS
"Namespace": "DO-NOT-EDIT-ME", // DO NOT EDIT THIS
"Name": "Example Breastplate",
"ToolTip": "This is a modded body armor.\nImmunity to 'On Fire!'\n+20 max mana and +1 max minions",
"ModifyTooltips": []
}
You can modify anything except TypeName, Namespace, Method and Value.

I recommend using Visual Studio Code as your editor.

File/Directory inside mode content folder
  • Info.json contains build properties like mod version and descriptions.

  • ModInfo.json contains properties of *.tmod files like mod name or version.

  • Items contains item properties like item name and tooltip.

  • NPCs contains NPC properties like name, chat texts and shop button texts.

  • Tiles contains map entries which need to be translated.

  • Miscs contains some other texts.

Repository page: https://github.com/mistzzt/tmodloader-mod-localizer
Download: https://github.com/mistzzt/tmodloader-mod-localizer/releases
 
Last edited:
Great work, I imagine people will be able to localise mod far more easily with this, especially if you can't get ahold of a mod owner for any reason.
(also Atom and Notepad++ are also great text editors)
 
Whenever I open the .exe file, it immediately closes. Any tips to fix this?
You need to made a shortcut of .exe file and go to properties of shortcut. Then in the way to the .exe file add this :
1. --mode dump <Mod Name> : That's will make a new folder with all files what can be translated from the mod what you selected and put instead of
<Mod Name>. Example: --mode dump ExampleMod.tmod.
2a. If you made a translation, you need to save the file and convert to .tmod file.
You need in the end add this, but you need delete this line : --mode dump ExampleMod.tmod.
2b. --mode patch --folder <content path> --language <language> [Mod file]
Example : --mode patch --folder ExampleModContent --language Chinese ExampleMod.tmod
That's all ;)
 
You need to made a shortcut of .exe file and go to properties of shortcut. Then in the way to the .exe file add this :
1. --mode dump <Mod Name> : That's will make a new folder with all files what can be translated from the mod what you selected and put instead of
<Mod Name>. Example: --mode dump ExampleMod.tmod.
2a. If you made a translation, you need to save the file and convert to .tmod file.
You need in the end add this, but you need delete this line : --mode dump ExampleMod.tmod.
2b. --mode patch --folder <content path> --language <language> [Mod file]
Example : --mode patch --folder ExampleModContent --language Chinese ExampleMod.tmod
That's all ;)
Thank you.
 
C:\Users\sword\Desktop\Mod.Localizer_0.2>C:\Users\sword\Desktop\Mod.Localizer_0.2\Mod.Localizer.exe --mode dump C:\Users\sword\Desktop\Mod.Localizer_0.2\CalamityMod.tmod
10:44:23 |Debug |Mod.Localizer.Program |Mod.Localizer started. (v0.2.0.0)
10:44:23 |Error |Mod.Localizer.Program |Unhandled Exception
================
2020/1/22 上午 10:44:23: Unhandled Exception
Culture: zh-TW
Exception: System.Reflection.TargetInvocationException: 引動過程的目標傳回例外狀況。 ---> System.IO.EndOfStreamException: 無法讀取資料流末端之外。
於 System.IO.BinaryReader.ReadString()
於 Terraria.ModLoader.IO.TmodFile.Read(LoadedState desiredState, ReadStreamingAsset streamingHandler)
--- 內部例外狀況堆疊追蹤的結尾 ---
於 System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
於 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
於 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
於 Mod.Localizer.TmodFileWrapper.TmodFileImplementation.InvokeMethod[T](Object instance, String method, Object[] parameters) 於 C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\TmodFileWrapper.cs: 行 178
於 Mod.Localizer.TmodFileWrapper.TmodFile.Read() 於 C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\TmodFileWrapper.cs: 行 258
於 Mod.Localizer.TmodFileWrapper.LoadFile(String path) 於 C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\TmodFileWrapper.cs: 行 31
於 Mod.Localizer.Program.Process() 於 C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\Program.cs: 行 37
於 Mod.Localizer.Program.Main(String[] args) 於 C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\Program.cs: 行 269
================


這個錯誤 該如何解決?
 
i'm sorry but i don't understand what you mean by that...
could you help me?
is there a video tutorial somewhere in english?

Yeah I also don't understand. Do you mean add "--mode dump mod_name.tmod" of the "Target" property in the properties tab? I tried that and got this error:

10:58:38 |Debug |Mod.Localizer.Program |Mod.Localizer started. (v0.2.0.0)
10:58:39 |Error |Mod.Localizer.Program |Unhandled Exception
================
1/28/2020 10:58:39 AM: Unhandled Exception
Culture: en-US
Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Ionic.Zlib.ZlibException: Bad state (invalid block type)
at Ionic.Zlib.InflateManager.Inflate(FlushType flush)
at Ionic.Zlib.ZlibCodec.Inflate(FlushType flush)
at Ionic.Zlib.ZlibBaseStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at Ionic.Zlib.DeflateStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.Stream.ReadByte()
at System.IO.BinaryReader.ReadByte()
at System.IO.BinaryReader.Read7BitEncodedInt()
at System.IO.BinaryReader.ReadString()
at Terraria.ModLoader.IO.TmodFile.Read(LoadedState desiredState, ReadStreamingAsset streamingHandler)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Mod.Localizer.TmodFileWrapper.TmodFileImplementation.InvokeMethod[T](Object instance, String method, Object[] parameters) in C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\TmodFileWrapper.cs:line 178
at Mod.Localizer.TmodFileWrapper.TmodFile.Read() in C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\TmodFileWrapper.cs:line 258
at Mod.Localizer.TmodFileWrapper.LoadFile(String path) in C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\TmodFileWrapper.cs:line 31
at Mod.Localizer.Program.Process() in C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\Program.cs:line 37
at Mod.Localizer.Program.Main(String[] args) in C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\Program.cs:line 269
================
 
I have a question, does this generate a new version of the mod, or does it create a new dependant mod that needs the original mod to work?
 
Yeah I also don't understand. Do you mean add "--mode dump mod_name.tmod" of the "Target" property in the properties tab? I tried that and got this error:

10:58:38 |Debug |Mod.Localizer.Program |Mod.Localizer started. (v0.2.0.0)
10:58:39 |Error |Mod.Localizer.Program |Unhandled Exception
================
1/28/2020 10:58:39 AM: Unhandled Exception
Culture: en-US
Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Ionic.Zlib.ZlibException: Bad state (invalid block type)
at Ionic.Zlib.InflateManager.Inflate(FlushType flush)
at Ionic.Zlib.ZlibCodec.Inflate(FlushType flush)
at Ionic.Zlib.ZlibBaseStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at Ionic.Zlib.DeflateStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.Stream.ReadByte()
at System.IO.BinaryReader.ReadByte()
at System.IO.BinaryReader.Read7BitEncodedInt()
at System.IO.BinaryReader.ReadString()
at Terraria.ModLoader.IO.TmodFile.Read(LoadedState desiredState, ReadStreamingAsset streamingHandler)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Mod.Localizer.TmodFileWrapper.TmodFileImplementation.InvokeMethod[T](Object instance, String method, Object[] parameters) in C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\TmodFileWrapper.cs:line 178
at Mod.Localizer.TmodFileWrapper.TmodFile.Read() in C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\TmodFileWrapper.cs:line 258
at Mod.Localizer.TmodFileWrapper.LoadFile(String path) in C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\TmodFileWrapper.cs:line 31
at Mod.Localizer.Program.Process() in C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\Program.cs:line 37
at Mod.Localizer.Program.Main(String[] args) in C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\Program.cs:line 269
================
I might be necroposting, but I got pretty much the same error
 
help:

12:48:29 |Debug |Mod.Localizer.Program |Mod.Localizer started. (v0.2.0.0)
12:48:29 |Error |Mod.Localizer.Program |Unhandled Exception
================
13.11.2020 12:48:29: Unhandled Exception
Culture: ru-RU
Exception: System.Reflection.TargetInvocationException: Адресат вызова создал исключение. ---> System.ArgumentException: Слишком кроткая или длинная часть строки версии.
в System.Version.VersionResult.SetFailure(ParseFailureKind failure, String argument)
в System.Version.TryParseVersion(String version, VersionResult& result)
в System.Version.Parse(String input)
в System.Version..ctor(String version)
в Terraria.ModLoader.IO.TmodFile.Read(LoadedState desiredState, ReadStreamingAsset streamingHandler)
--- Конец трассировки внутреннего стека исключений ---
в System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
в System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
в System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
в Mod.Localizer.TmodFileWrapper.TmodFileImplementation.InvokeMethod[T](Object instance, String method, Object[] parameters) в C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\TmodFileWrapper.cs:строка 178
в Mod.Localizer.TmodFileWrapper.TmodFile.Read() в C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\TmodFileWrapper.cs:строка 258
в Mod.Localizer.TmodFileWrapper.LoadFile(String path) в C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\TmodFileWrapper.cs:строка 31
в Mod.Localizer.Program.Process() в C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\Program.cs:строка 37
в Mod.Localizer.Program.Main(String[] args) в C:\Users\zitwa\Sources\Repos\tmodloader-mod-localizer\Mod.Localizer\Program.cs:строка 269
================
 
Back
Top Bottom