autotranslating dialogs

Use this forum to help develop your game-making skills, and get feedback on writing, art, music, or anything else you've created that isn't attached to a game in progress.
Locked
Message
Author
3ae60k
Newbie
Posts: 2
Joined: Mon Feb 16, 2009 2:51 pm
Contact:

autotranslating dialogs

#1 Post by 3ae60k »

hello... i have a idea how to translate dialogs in any game...
for example "jisei" from http://games.renpy.org/game/jisei.shtml

simple hook output text and translate with google.

/renpy/display/text.py

+21 "import trans"


#super(Text, self).__init__(style=style, **properties)


#self.text = text
+663 "print trans.translate(self.text,'en','ru')" //print translate to stdout
#self.pause = pause

#self.keep_pausing = False

#self.pause_length = None

#self.tokenized = tokenized
-----

trans.py

Code: Select all

import re
import sys
import urllib
import simplejson
 
baseUrl = "http://ajax.googleapis.com/ajax/services/language/translate"
 
def getSplits(text,splitLength=4500):
    '''
    Translate Api has a limit on length of text(4500 characters) that can be translated at once, 
    '''
    return (text[index:index+splitLength] for index in xrange(0,len(text),splitLength))
 
 
def translate(text,src='', to='en'):
    '''
    A Python Wrapper for Google AJAX Language API:
    * Uses Google Language Detection, in cases source language is not provided with the source text
    * Splits up text if it's longer then 4500 characters, as a limit put up by the API
    '''
 
    params = ({'langpair': '%s|%s' % (src, to),
             'v': '1.0'
             })
    retText=''
    for text in getSplits(text):
            params['q'] = text
            resp = simplejson.load(urllib.urlopen('%s' % (baseUrl), data = urllib.urlencode(params)))
            try:
                    retText += resp['responseData']['translatedText']
            except:
                    raise
    return retText
 
 
def test():
    msg = "      Write something You want to be translated to English,\n"\
        "      Enter ctrl+c to exit"
    print msg
    while True:
        text = raw_input('#>  ')
        retText = translate(text)
        print retText
 
 
if __name__=='__main__':
    try:
        test()
    except KeyboardInterrupt:
        print "\n"
        sys.exit(0)


result:

Image

Tsuki-chan
Regular
Posts: 132
Joined: Mon Sep 01, 2008 10:13 pm
Projects: How to Be a Successful Villain
Location: Georgia, US
Contact:

Re: autotranslating dialogs

#2 Post by Tsuki-chan »

Not sure how good of a translation you'd end up with if you went with Google Translate.
It's too bad there isn't currently a translator (as far as I know) that translates the entire sentence as opposed to word for word.

winternight119
Regular
Posts: 50
Joined: Thu Feb 26, 2009 10:17 pm
Projects: Under the Cherry Blossoms: Memories of a Dream 「桜の下で:夢の記憶」
Contact:

Re: autotranslating dialogs

#3 Post by winternight119 »

I don't think that automatic translation would be that error-prone, like Google Translate, though.

However the one problem I do see is that the translator might end up sounding robotic, while usually writing is in a certain style that best conveys the emotions and ideas that the writer is trying to present or give the effect of.
Current Project(s): 桜の下で:夢の記憶 「Under the Cherry Blossoms: Memories of a Dream」 - WIP - click here for more!

3ae60k
Newbie
Posts: 2
Joined: Mon Feb 16, 2009 2:51 pm
Contact:

Re: autotranslating dialogs

#4 Post by 3ae60k »

i have meand that it can help people who's know language bad(like me) to translate a game dialogs, it's not usable to play game without language knows. But if you know basics of language it help you to translate a text, comparing a computer-translate and your translate you can easily understand meaning, or when you doesn't know word you don't necessary to open dictionary.

tpgames
Regular
Posts: 53
Joined: Wed Jun 16, 2010 11:29 pm
Projects: Jade Universität
Contact:

Re: autotranslating dialogs

#5 Post by tpgames »

Actually, one german site is trying to get a 'word' in context translation going. You type in word and it will give you that word in German and english with how its used on various sites. Very cool!

google and other word to word translators are considered ALL wrong! However, the problem is between Colloquial and Text book. Textbook will always be wrong to a native speaker. those translators work well with toddler nouns - basically names of items. Anything else, and forget it! This is why I've gave up on having my site be multi-lingual between 9 languages. With Japanese, without knowing the Romanji, you never know if you have the right Kanji word, and its the Romanji that tells you which Kanji reading you mean. :P I gave up on learning Japanese for this reason. I will pick it up later, after I've learn German fluently. I'm sticking with German, Russian, and English for my site, only because I have a Russian friend who can help me with the word usage.

So...your idea doesn't totally work. Sorry!
Kyteroo jaunting off....(won't add website until I've finished 1 Ren'Py game)
WIP: Jade Universität - A RPG puzzle game.

Der Tor
Miko-Class Veteran
Posts: 513
Joined: Sun Jul 15, 2007 9:03 pm
Completed: Der Totengräber, There is always a Choice, Darkness
Projects: A Legend of an Ancient Evil
itch: emmanuel-goldstein
Location: Hinter dir
Contact:

Re: autotranslating dialogs

#6 Post by Der Tor »

No matter what site, what program or what method, you will never be able to substitute for a human translator... unless you want your translation to be really crappy and wanna be laughed at... :D

Here is my favorite sentence to enter into Babelfish:
"I put Ben Gay (muscle rub) on his wiener" :mrgreen:
We hit the translate button and get the German Translation:
Ich setzte Ben-Homosexuelles (Muskelunebenheit) auf sein Wiener Würstchen (which is already a completely different meaning)
We hit the button again and translate it back into English and we get:
"I set Ben homosexual (muscle unevenness) on its Viennese small sausage"

tpgames
Regular
Posts: 53
Joined: Wed Jun 16, 2010 11:29 pm
Projects: Jade Universität
Contact:

Re: autotranslating dialogs

#7 Post by tpgames »

That is just too funny! :mrgreen: :lol: I never liked to use Babelfish translator. Thats only because if I'm going to get inaccurate translations, I might as well use Google because its faster. :lol:
Kyteroo jaunting off....(won't add website until I've finished 1 Ren'Py game)
WIP: Jade Universität - A RPG puzzle game.

IceD
Veteran
Posts: 433
Joined: Sun Feb 01, 2009 6:15 pm
Contact:

Re: autotranslating dialogs

#8 Post by IceD »

You know - this is a good, interesting idea and something much better than nothing. I'd say it could at least find some use in testing purposes. But yeah - almost every existing trasnlation engine is prone to mistakes, because it does so mechanically, word by word without knowledge of what the writer had in mind; Different words put together can convey hundreds of meanings while the engines aren't able to tell apart beetwen them.

I hope that we will get a kind of sophisticated translator engine in the near future. That could be very useful.

LVUER
King of Lolies
Posts: 4538
Joined: Mon Nov 26, 2007 9:57 pm
Completed: R.S.P
Location: Bandung, West Java, Indonesia
Contact:

Re: autotranslating dialogs

#9 Post by LVUER »

If you write words in an auto-translator, and then translate those words back and forth, you'll get different meaning every time, and the result will get crazier and crazier.
"Double the princesses, quadruple the fun!" - Haken Browning (SRW-OG Endless Frontier)

DeviantArt Account
MoeToMecha Blog (under construction)
Lolicondria Blog (under construction) <- NSFW

Locked

Who is online

Users browsing this forum: No registered users