Multilingual game

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Leaden
Newbie
Posts: 15
Joined: Mon Jul 28, 2008 1:38 pm
Contact:

Multilingual game

#1 Post by Leaden »

Aloha, people!

I seeking best way to make and support more than two languages in visual novel. There I found some interesting solutions, but no one of them didn't solve major problem: it's better for translators to separate literary text and script commands. Especially good thing is to make text files for each language. But how?

JinzouTamashii
Eileen-Class Veteran
Posts: 1686
Joined: Mon Sep 21, 2009 8:03 pm
Projects: E-mail me if you wanna rock the planet
Location: USA
Contact:

Re: Multilingual game

#2 Post by JinzouTamashii »

Make a new text file and name it English.rpy and French.rpy for each one, perhaps?
Don't worry, we can get through it together. I didn't forget about you! I just got overwhelmed.
https://cherylitou.wordpress.com

Alex

Re: Multilingual game

#3 Post by Alex »

Привет! (hi)
Mmm, you can try this http://lemmasoft.renai.us/forums/viewto ... f=8&t=5814
Downloadable sample has comments in the code, so the part of it might be useful for you.
P.S. take it as my self-advertising...))

JinzouTamashii
Eileen-Class Veteran
Posts: 1686
Joined: Mon Sep 21, 2009 8:03 pm
Projects: E-mail me if you wanna rock the planet
Location: USA
Contact:

Re: Multilingual game

#4 Post by JinzouTamashii »

I bet that's just what Leaden wanted. :lol:
Don't worry, we can get through it together. I didn't forget about you! I just got overwhelmed.
https://cherylitou.wordpress.com

Leaden
Newbie
Posts: 15
Joined: Mon Jul 28, 2008 1:38 pm
Contact:

Re: Multilingual game

#5 Post by Leaden »

JinzouTamashii wrote:Make a new text file and name it English.rpy and French.rpy for each one, perhaps?
It's simple and reliable method, but only when your game finalized on one language and then translating into others. In other cases every change in script will multiply on amount of supported languages.

Leaden
Newbie
Posts: 15
Joined: Mon Jul 28, 2008 1:38 pm
Contact:

Re: Multilingual game

#6 Post by Leaden »

Alex wrote:Привет! (hi)
Mmm, you can try this http://lemmasoft.renai.us/forums/viewto ... f=8&t=5814
Downloadable sample has comments in the code, so the part of it might be useful for you.
P.S. take it as my self-advertising...))
Здравствуй, товарищ!
Thanks for example. There some intresting ideas, but in general this solution not suitable. Binding to string numbers not flexible and don't allow to insert comments for tranlators and readability. And this example works on very simple game: linear, without pictures, characters, menus. Sorry, but I want more :o)

Leaden
Newbie
Posts: 15
Joined: Mon Jul 28, 2008 1:38 pm
Contact:

Re: Multilingual game

#7 Post by Leaden »

May be one of 189 games on RenPy have that feature that I talked about?

Alex

Re: Multilingual game

#8 Post by Alex »

And this example works on very simple game: linear, without pictures, characters, menus.
?!
everything can be included as usual... if you still interested in more comments about it you can mail me Lex__2007@mail.ru

Leaden
Newbie
Posts: 15
Joined: Mon Jul 28, 2008 1:38 pm
Contact:

Re: Multilingual game

#9 Post by Leaden »

Alex wrote:
And this example works on very simple game: linear, without pictures, characters, menus.
?!
everything can be included as usual... if you still interested in more comments about it you can mail me Lex__2007@mail.ru
Theoreticaly yes, but try this on practise ;) Update you example with dialog tree and you will see what I'm worry for.
And I like to stay in public discussion, because it may be useful for someone else.

Alex

Re: Multilingual game

#10 Post by Alex »

Theoreticaly yes, but try this on practise
Well, for example - slightly modified "The question" (sorry, this one once again)
http://rapidshare.com/files/299279550/t ... transl.zip
http://rapidshare.com/files/299280222/t ... 86.tar.bz2
http://rapidshare.com/files/299280773/t ... sl-mac.zip
In preferences you can change game language.
I believe you can easily add another translation (make "lang2.txt" and "Translated__3.rpy" and place them in game folder)
Here it is a part of code:

Code: Select all

... ... ...
# The game starts here.
label start:

    scene black
    call after_load from _after_load_2
    
    $ bl_game = False
    
    play music "illurock.ogg"

    scene bg lecturehall
    with fade

    $ q (None, 5)
    $ q (None, 6)
    $ q (None, 7)
    $ q (None, 8)
    $ q (None, 9)
    
    scene bg uni
    with fade

    $ q (None, 10)
    
    show sylvie normal
    with dissolve
    
    $ q (None, 11)
    $ q (None, 12)
    $ q (None, 13)
    $ q (None, 14)
    $ q (None, 15)
    $ q (None, 16)
    $ q (None, 17)
    $ q (None, 18)
    $ q (None, 19)
    
    $ menu_0 = ph[lang][20]
    $ menu_1 = ph[lang][21]

    menu:

        "%(menu_0)s":
        
            jump rightaway
            
        "%(menu_1)s":
        
            jump later
       ... ... ...

Papaxibe
Newbie
Posts: 7
Joined: Wed Apr 18, 2007 2:04 am
Projects: Season of Sakura Brasil
Location: Brazil
Contact:

Re: Multilingual game

#11 Post by Papaxibe »

Well, well... I have the same problem, Leaden.

After all my hard work developing the script in Portuguese, how make the game become multilingual? I don't know if my solution is a good way... but it is a soft solution.

1st step:

Insert into file \renpy\config.py the following variable:

Code: Select all

current_idiom = 0
2nd step:

Edit the file \renpy\display\text.py, the code of all the text showed in the screen:

about the line 897:

Code: Select all

        tokens = [ ]
        for l in self.tokens:
            tokens.extend(l)

        ti = iter(tokens)
        
        ##---------------------------------------------------------------------------
        ##begin of multilingual code
        ##---------------------------------------------------------------------------

        if ("tag", "t") in tokens:
            
            if renpy.config.current_idiom == 0:
                
                tsl[-1].size = self.style.size
                
            else:
                
                tsl[-1].size = 0
                
            tsl[-1].update()

        ##---------------------------------------------------------------------------
        ##end of multilingual code
        ##---------------------------------------------------------------------------

        for kind, i in ti:

            # Newline.
            if kind == "newline":
                triples.append(("newline", tsl[-1], ""))                
                continue
about the line 1025:

Code: Select all

                    tsl[-1].strikethrough = style.strikethrough
                    tsl[-1].color = style.color
                    tsl[-1].black_color = style.black_color
                    tsl[-1].update()

        ##---------------------------------------------------------------------------
        ##begin of multilingual code
        ##---------------------------------------------------------------------------

                elif i == "t":
                    
                    if renpy.config.current_idiom == 0:
                    
                        tsl[-1].size = 0
                        
                    else:
                        
                        tsl[-1].size = self.style.size

                    tsl[-1].update()

        ##---------------------------------------------------------------------------
        ##end of multilingual code
        ##---------------------------------------------------------------------------

                elif i.startswith("font"):

                    m = re.match(r'font=(.*)', i)
3rd Step:

Now, you must add the tag {t}translated text{/t} into your script, everywhere you want change the idiom.

Example, The Question:

Code: Select all

# The game starts here.
label start:

    $ config.current_idiom = 1 ## this line change the idiom to Portuguese

    $ bl_game = False
    
    play music "illurock.ogg"

    scene bg lecturehall
    with fade

    "Well, professor Eileen's lecture was interesting.{t}Bem, a palestra da professora Eileen foi interessante.{/t}"
    "But to be honest, I couldn't concentrate on it very much.{t}Mas para ser bem honesto, Eu não consegui me concentrar muito bem.{/t}"
    "I had a lot of other thoughts on my mind.{t}Estava pensando em muitas outras coisas.{/t}"
    "And they all ended up with a question.{t}E todas acabavam numa pergunta.{/t}"
    "A question, I've been meaning to ask someone.{t}Uma pergunta, que eu terei de fazer à alguém.{/t}"

    scene bg uni
    with fade
We can create any type of handler to change the idiom, just change the value of the config variable current_idiom change the idiom of the text.

I know, edit the code of text.py isn't good, because you may have instable behavior, and a future release doesn't complain your changes.

Thanks for attention!

Papaxibé
Attachments
script.rpy
(5.62 KiB) Downloaded 43 times
text.py
(44.42 KiB) Downloaded 36 times
Enquanto as andorinhas pastarem a relva selvagem, e os elefantes salpicarem de galho em galho, um velho sentado na pedra de pau, calado assim dizia: os três sábios da antiguidade eram quatro, Danúbio e Jacó.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Ocelot