[SOLVED] How to Define Text Styles To Facilitate Translation?

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
User avatar
Obscura
Eileen-Class Veteran
Posts: 1431
Joined: Fri Mar 09, 2012 6:58 pm
Projects: Coming Out On Top
Location: United States
Contact:

[SOLVED] How to Define Text Styles To Facilitate Translation?

#1 Post by Obscura »

My game contains several text styles. For the purposes of simplification, let's say there are two:

1. default font for dialogue
2. diary font for when the player writes in their diary

They are defined accordingly below:

Code: Select all

init -1 python hide:
  style.default.font = "arial.ttf"

init:
  define diary = Character(None,
    color = "000",
    what_font= "cursive.ttf")  

diary "Dear Diary, today was my birthday."
In order to change the default font, I use something like:

Code: Select all

translate None style default:
  font "arial.ttf"

translate spanish style default:
  font "spanish.ttf"  
A textbutton allows the player to change the language. The dialogue font will change accordingly.

What can I do to change the DIARY font when the player changes the language to Spanish?

Thanks!
Last edited by Obscura on Sun Jan 20, 2019 3:58 pm, edited 3 times in total.
Coming Out On Top - An Adult Gay Dating Sim
website

User avatar
Obscura
Eileen-Class Veteran
Posts: 1431
Joined: Fri Mar 09, 2012 6:58 pm
Projects: Coming Out On Top
Location: United States
Contact:

Re: How to Define Text Styles To Facilitate Translation?

#2 Post by Obscura »

Ok, answering my own question here in case it helps anybody...

It seems that you'd need to define a style for the diary, then use the translate command to tell Renpy which font to substitute for that style.

Code: Select all

init -1 python hide:
  style.default.font = "arial.ttf"

init python:
  style.say_diary_bubble = Style(style.default)
  style.say_diary_bubble.font = "fonts/cursive.ttf"
  
init:
  define diary = Character(None,
    color = "000",
    what_style="say_diary_bubble")
    
translate None style default:
  font "arial.ttf"

translate spanish style default:
  font "spanish.ttf"  
  
translate spanish style say_diary_bubble:
  font "spanish_cursive.ttf" #or whatever font you want to use for a Spanish version of the diary
 
Note: This seems to work ok, of course I don't know if this code is the most efficient or sensible. :roll:
Coming Out On Top - An Adult Gay Dating Sim
website

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: How to Define Text Styles To Facilitate Translation?

#3 Post by IrinaLazareva »

Theoretically, it should work like this:

Code: Select all

define diary = Character(None, what_font= _("cursive.ttf"))
The problem is, it doesn't work. Translation is created:

Code: Select all

translate spanish strings:
    old "cursive.ttf"
    new "spanish.ttf"
but for unknown reasons, the program does not respond to changes.
Maybe it's a bug. But this is not accurate information...
Obscura wrote: Sun Jan 20, 2019 3:48 pm This seems to work ok, of course I don't know if this code is the most efficient or sensible. :roll:
if it works, the rest of it doesn't matter. :)

User avatar
Obscura
Eileen-Class Veteran
Posts: 1431
Joined: Fri Mar 09, 2012 6:58 pm
Projects: Coming Out On Top
Location: United States
Contact:

Re: [SOLVED] How to Define Text Styles To Facilitate Translation?

#4 Post by Obscura »

I had no idea you could use _() with actual file names! At least potentially...because that's a clever method...I wonder why it doesn't work. :? Maybe the translation doesn't occur early enough in the initialization process?
Coming Out On Top - An Adult Gay Dating Sim
website

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: [SOLVED] How to Define Text Styles To Facilitate Translation?

#5 Post by IrinaLazareva »

I've been thinking about it, too, but my experiments to change the initialization stages have not led to anything.., for now.

Post Reply

Who is online

Users browsing this forum: Google [Bot]