Others None The memory a robot girl spins, #1 #2, Translation tools (Needed to tl game. Extra translator needed!)

Jonny00

New Member
Nov 2, 2017
7
7
So I looked through the game-files a bit. Translating the files is a nightmare haha. Game is written in Ruby too, that's way out of my comfort zone.
BUT

I'm pretty sure you can inject code to generate mtl in realtime before the text is displayed (it's written in ruby, you can easily write it, if you know the language, which I don't)

Found a class called Image_Message.rb under /src which seems to do all the parsing/ displaying of text so if you translate the incoming text there (see image)... you might have an mtl-translated game.

Capture.PNG


I also done some research and it seems there's a library that can do mtl. It's called to_lang.

So if somebody with time on their hand wants to try, this would probably lead to some good results.

edit: or above that there's a function called draw_text(x, y, text). You could mtl it there too so you have more context but you might break something maybe.

edit2: this is what I mean, seems a bit tricky but totally doable. Sadly I don't have the time on my hand, so imma leave this here:
Capture2.PNG
 
Last edited:

TheLoliRealm

Member
Jan 4, 2022
210
177
So I looked through the game-files a bit. Translating the files is a nightmare haha. Game is written in Ruby too, that's way out of my comfort zone.
BUT

I'm pretty sure you can inject code to generate mtl in realtime before the text is displayed (it's written in ruby, you can easily write it, if you know the language, which I don't)

Found a class called Image_Message.rb under /src which seems to do all the parsing/ displaying of text so if you translate the incoming text there (see image)... you might have an mtl-translated game.

Capture.PNG


I also done some research and it seems there's a library that can do mtl. It's called to_lang.

So if somebody with time on their hand wants to try, this would probably lead to some good results.

edit: or above that there's a function called draw_text(x, y, text). You could mtl it there too so you have more context but you might break something maybe.

edit2: this is what I mean, seems a bit tricky but totally doable. Sadly I don't have the time on my hand, so imma leave this here:
View attachment 2922967

We've been constantly updating the tools to help make translation easier, so if you'd wanna participate I could rope you in
 
  • Like
Reactions: PunpunRen

Jonny00

New Member
Nov 2, 2017
7
7
We've been constantly updating the tools to help make translation easier, so if you'd wanna participate I could rope you in
I might take a look at it if I get horny enough.
But that'll have to wait for at least a month since life is kicking my butt right now haha
 

Quite Frankly

Member
Jul 25, 2017
158
29
So I looked through the game-files a bit. Translating the files is a nightmare haha. Game is written in Ruby too, that's way out of my comfort zone.
BUT

I'm pretty sure you can inject code to generate mtl in realtime before the text is displayed (it's written in ruby, you can easily write it, if you know the language, which I don't)

Found a class called Image_Message.rb under /src which seems to do all the parsing/ displaying of text so if you translate the incoming text there (see image)... you might have an mtl-translated game.

Capture.PNG


I also done some research and it seems there's a library that can do mtl. It's called to_lang.

So if somebody with time on their hand wants to try, this would probably lead to some good results.

edit: or above that there's a function called draw_text(x, y, text). You could mtl it there too so you have more context but you might break something maybe.

edit2: this is what I mean, seems a bit tricky but totally doable. Sadly I don't have the time on my hand, so imma leave this here:
View attachment 2922967
what program did you use to edit this and how did you recompile it back into the original game?
 
Last edited:

Jonny00

New Member
Nov 2, 2017
7
7
what program did you use to edit this and how did you recompile it back into the original game?
You don't need to, ruby uses an interpreter, not compiler. You can just use a regular text-editor for this (although I'd recommend IDEs). For a quick example I just used Notepad++ in dark mode
 

devokin

New Member
Dec 3, 2020
7
7
So I looked through the game-files a bit. Translating the files is a nightmare haha. Game is written in Ruby too, that's way out of my comfort zone.
BUT

I'm pretty sure you can inject code to generate mtl in realtime before the text is displayed (it's written in ruby, you can easily write it, if you know the language, which I don't)

Found a class called Image_Message.rb under /src which seems to do all the parsing/ displaying of text so if you translate the incoming text there (see image)... you might have an mtl-translated game.

Capture.PNG


I also done some research and it seems there's a library that can do mtl. It's called to_lang.

So if somebody with time on their hand wants to try, this would probably lead to some good results.

edit: or above that there's a function called draw_text(x, y, text). You could mtl it there too so you have more context but you might break something maybe.

edit2: this is what I mean, seems a bit tricky but totally doable. Sadly I don't have the time on my hand, so imma leave this here:
View attachment 2922967
The issue with draw_text is that it's called for each letter/frame to give a "typing" effect.
I made a ruby function that sends text to sugoi offline translator, but without getting the full string at once it's slow.
 
Last edited:

devokin

New Member
Dec 3, 2020
7
7
By hooking into Window_Message.add_message and Window_BattleMessage.add_message
MTL can be added to all dialog.

sugoi translator isn't meant to be used like this, so translation time is around 1-0.3 seconds per dialog. There's also no saving of already translated text, but heres the code:


Code:
require 'net/http'
require 'json'
require 'uri'
def translate(text)
uri = URI('http://localhost:14366/')
 Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
   request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
   request.body = {message:"translate sentences",content:text}.to_json
   response = http.request request
   return response.body
 end
end
You have to hook Window_BattleMessage.add_message like this:

Code:
  def add_message(str, image = nil, side = :top)
    str = translate(str)
And Window_Message.add_message like this:

Code:
  def add_message(str, face = nil, side = nil, type = :message)
    if face.nil?
      @sprite_face.image = nil
    elsif face.instance_of?(Image)
      @sprite_face.image = face
    elsif face.instance_of?(String)
      begin
        @sprite_face.image = Image.load(face)
      rescue
        @sprite_face.image = nil
      end
    end
    @size = 0
    @side = side
    @type = str == "" ? :clear : type
    trans = translate(str)
    @message = trans
    Sprite_MessageLog.add_message(trans)
  end
And this is what you get:
Screenshot.png
It'd be much better to translate the files that store the text though.
 
Last edited:

Jonny00

New Member
Nov 2, 2017
7
7
By hooking into Window_Message.add_message and Window_BattleMessage.add_message
MTL can be added to all dialog.

sugoi translator isn't meant to be used like this, so translation time is around 1-0.3 seconds per dialog. There's also no saving of already translated text, but heres the code:


Code:
require 'net/http'
require 'json'
require 'uri'
def translate(text)
uri = URI('http://localhost:14366/')
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
   request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
   request.body = {message:"translate sentences",content:text}.to_json
   response = http.request request
   return response.body
end
end
You have to hook Window_BattleMessage.add_message like this:

Code:
  def add_message(str, image = nil, side = :top)
    str = translate(str)
And Window_Message.add_message like this:

Code:
  def add_message(str, face = nil, side = nil, type = :message)
    if face.nil?
      @sprite_face.image = nil
    elsif face.instance_of?(Image)
      @sprite_face.image = face
    elsif face.instance_of?(String)
      begin
        @sprite_face.image = Image.load(face)
      rescue
        @sprite_face.image = nil
      end
    end
    @size = 0
    @side = side
    @type = str == "" ? :clear : type
    trans = translate(str)
    @message = trans
    Sprite_MessageLog.add_message(trans)
  end
And this is what you get:
View attachment 3008436
It'd be much better to translate the files that store the text though.
Really cool! I got it working with your code too. I put the http-post call into a new thread and just read the translation from the terminal. Like that there's less lag. But you might as well use Textractor, although that one's also kinda broken.

Too bad it doesn't translate the menu, missions, items and all that. I looked through the files but dunno really where to inject code for that properly.

But you're right, it's better to translate the files instead.
 
  • Like
Reactions: RrrT232

devokin

New Member
Dec 3, 2020
7
7
Really cool! I got it working with your code too. I put the http-post call into a new thread and just read the translation from the terminal. Like that there's less lag. But you might as well use Textractor, although that one's also kinda broken.

Too bad it doesn't translate the menu, missions, items and all that. I looked through the files but dunno really where to inject code for that properly.

But you're right, it's better to translate the files instead.
Making it a threaded call is a great idea!
Storing it in a file backed dictionary would solve the delay for highly used strings like menus and items.

The way I found those functions was by using jetbrain's find usages tool in their IDEs, just keep backtracking what caused draw_text to get called. For example Image_mesage.draw_text is called by Window_origin.draw_text, and thats called by a whole lot of classes associated with the menu system:
1697945523146.png
Those are probably where you'd hook.

But now that I think of it though, a dictionary and just a single hook on draw_text would stop it from translating every single frame and not require all these classes to be hooked... Not sure if the typing effect would make that possible though, maybe it'd depend on which draw_text idk
 
Last edited:
  • Like
Reactions: RrrT232

Quite Frankly

Member
Jul 25, 2017
158
29
Did you just make the edits using notepad++ and if so what exactly did you do or what exactly was done so we can replicate it?

Or maybe its just easier for us to buy the files which were modified off of you? Please share your edited ruby files.
 
Last edited:

Jonny00

New Member
Nov 2, 2017
7
7
Did you just make the edits using notepad++ and if so what exactly did you do or what exactly was done so we can replicate it?

Or maybe its just easier for us to buy the files which were modified off of you? Please share your edited ruby files.
I just did what the person above me posted. It's just about modifying 2 files in the src folder (it's a hidden folder in the game), I'll post them here. You'll need to download the sugoi auto-translator to make it work.

Honestly I think using textractor is a better call though, and just use some OCR translation for the trickier parts (e.g. google translate on your phone)

The game runs on a really old version of ruby so most of the libraries just don't work with it, you can't even download the toolkit for that ruby version anymore (at least i couldn't find it). I tried working on it, but it's just not worth the time when the quality will be only a bit better then what textractor gives you.

There's one good IDE if you wanna have a go at it, RubyMine. But it's a trial version so I just used VS Code instead, but it has way less support for ruby. Notepad++ is also possible honestly.

Maybe finding a good manual hook for textractor might be another good approach for MTL, but I don't know how to do that haha.
 
  • Red Heart
Reactions: Quite Frankly

Quite Frankly

Member
Jul 25, 2017
158
29
I just did what the person above me posted. It's just about modifying 2 files in the src folder (it's a hidden folder in the game), I'll post them here. You'll need to download the sugoi auto-translator to make it work.

Honestly I think using textractor is a better call though, and just use some OCR translation for the trickier parts (e.g. google translate on your phone)

The game runs on a really old version of ruby so most of the libraries just don't work with it, you can't even download the toolkit for that ruby version anymore (at least i couldn't find it). I tried working on it, but it's just not worth the time when the quality will be only a bit better then what textractor gives you.

There's one good IDE if you wanna have a go at it, RubyMine. But it's a trial version so I just used VS Code instead, but it has way less support for ruby. Notepad++ is also possible honestly.

Maybe finding a good manual hook for textractor might be another good approach for MTL, but I don't know how to do that haha.
Can you walk me thru how to setup sugoi and translator++?I am running sugoi translator thru an external harddrive because its over 3gb. How do you load the game into translator++ to get it to inject english into the application?

I am getting this I don't know if I'm doing this right. I tried to Integrate Sugoi with Translator ++ following the online tutorial on google, which I think is what you said needs to be done. It looks like because I saved sugoi to the external drive for some reason translator++ doesn't find it? I don't know what to do. One of my hobbies is trying to learn these translation applications, but they've become increasingly complex over the last 10 yrs.



What is it that I need to do with this code?

require 'net/http'
require 'json'
require 'uri'
def translate(text)
uri = URI(' ')
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
request = Net::HTTP::post.new(uri, 'Content-Type' => 'application/json')
request.body = {message:"translate sentences",content:text}.to_json
response = http.request request
return response.body
end
end
 
Last edited:

Quite Frankly

Member
Jul 25, 2017
158
29
i don't know how to inject what i got from the server into the game like you did . please help. If you want to explain technically what is going on, i'm eager to know.
 
Last edited:

Jonny00

New Member
Nov 2, 2017
7
7
i don't know how to inject what i got from the server into the game like you did . please help. If you want to explain technically what is going on, i'm eager to know.
I think you're mixing a couple of things here, but congrats on getting it working somehow!

Textractor is it's own tool that hooks into games to translate what it finds.
Sugoi Autotranslator is a translator we use here to translate stuff without needing internet. You CAN hook it up to textractor or translator++, but they work without it (and probably better too).
Translator++ is yet another tool to dig through (mostly RPG Maker) games and find text which then makes you able to translate it before putting it back together (either by hand or using sugoi autotranslator, or something else like google, bing, yandex, ...). This one doesn't work well here since Translator++ doesn't know the game engine used here.

The way i programmed it, it's supposed to show the translation outside of the game, so it doesn't lag. That's why in the file src/Window_BattleMessage.rb & src/Window_Message the translate-function is defined with "new Thead"

Code:
  require 'net/http'
  require 'json'
  require 'uri'
  def translate(text)
    Thread.new do
      uri = URI('http://localhost:14366/')
      Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
        request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
        request.body = {message:"translate sentences",content:text}.to_json
        response = http.request request
        return response.body
      end
    end
  end
That's why I said using textractor does the same thing.

If you want to see it in game (which will cause massive lag) you'll need to copy-paste devokin's code into the files. Just overwrite the functions with what he wrote (it's 4 functions in total, 2 in each file). The add_message functions here are used by the game to display some text, we just hooked up a translate function into it to get us the translation.

edit: also for context: sugoi autotranslator offline mode (which is used here) hosts its own server locally for your machine. that's why the HTTP.start stuff is being done in the code. The idea was to prevent lag by having to wait for calls over the internet, which might not respond with a translation, but a rejection. Turns out it's too slow though

edit2: also, just in case you got it mixed up, notepad++ is just a better text-editor, nothing to do with translations.
 
Last edited: