Is there a way to know in which language is the game right now?

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
Karrion
Regular
Posts: 73
Joined: Fri Jan 18, 2019 8:33 pm
Projects: Murder on the Marine Express
Organization: 1564 Studio
itch: 1564-studio
Contact:

Is there a way to know in which language is the game right now?

#1 Post by Karrion »

So, I'm using this code

Code: Select all

text _("((No new messages))"):
                    if lang == "spanish":
                        xpos 150
                    else:
                        xpos 200
                    ypos 10
                    size 90
                    color "#7693BF"
because in spanish the phase is not centered, while in english, it is. Thing is, when I execute that, ren'py says lang is not defined, and persistent.lang seems to be defined but does not affect the condition, it always goes to the else clause. What am I doing wrong?
1564 Studio, an indie studio dedicated to developing mystery VNs!
Follow us on Twitter for updates on our projects!

Image

Check out our current project, just released on PC, Android, Switch, XBox ONE/Series S/X and PS4/5!
Also available in Spanish, English, French and Japanese!

Image

tornsoul
Regular
Posts: 29
Joined: Sat Jun 19, 2021 7:32 pm
Contact:

Re: Is there a way to know in which language is the game right now?

#2 Post by tornsoul »

Are you *100%* sure that you have enough room for the (long spanish) text in whatever "box" you are placing it in?

Sounds like it might not have enough room - and thus "overflows" the box it's in (and thus looks as if it's not centered, because it's taking up all the box + a bit)

User avatar
Karrion
Regular
Posts: 73
Joined: Fri Jan 18, 2019 8:33 pm
Projects: Murder on the Marine Express
Organization: 1564 Studio
itch: 1564-studio
Contact:

Re: Is there a way to know in which language is the game right now?

#3 Post by Karrion »

Yup, the problem is just that it's longer:

Spanish: https://i.imgur.com/9Z8Xi9E.png
English: https://i.imgur.com/AAbOii3.png
1564 Studio, an indie studio dedicated to developing mystery VNs!
Follow us on Twitter for updates on our projects!

Image

Check out our current project, just released on PC, Android, Switch, XBox ONE/Series S/X and PS4/5!
Also available in Spanish, English, French and Japanese!

Image

User avatar
emz911
Regular
Posts: 103
Joined: Fri Jun 23, 2017 2:23 pm
Contact:

Re: Is there a way to know in which language is the game right now?

#4 Post by emz911 »

Xpos is a specific coordinate, if you want to center the text despite its length, use xcenter or xalign

tornsoul
Regular
Posts: 29
Joined: Sat Jun 19, 2021 7:32 pm
Contact:

Re: Is there a way to know in which language is the game right now?

#5 Post by tornsoul »

ah yes - I was assuming he was already centering - and the code we saw was just an attempt to fix.

Do yourself a favor and use centering (xcenter or xalign) in this case - then you don't have to worry about the language.

User avatar
Karrion
Regular
Posts: 73
Joined: Fri Jan 18, 2019 8:33 pm
Projects: Murder on the Marine Express
Organization: 1564 Studio
itch: 1564-studio
Contact:

Re: Is there a way to know in which language is the game right now?

#6 Post by Karrion »

I've been trying to use xalign 0.5 and the result is this:

https://i.imgur.com/ACWyKbd.png
https://i.imgur.com/3KBJSnL.png

And by trying to adjust the value, it seems that both end up misaligned with one another, same problem that I had with xpos. I'll paste the whole code of the screen to see if it sheds some light into the issue:

Code: Select all

screen chat_log(log):
    viewport id "chatlog":
        mousewheel True
        draggable True
        if not(log.history()):
            text _("((No new messages))"):
                xalign 0.5
                ypos 10
                size 90
                color "#7693BF"
        vbox:
            spacing 10
            for type, kwargs in log.history():
                use expression type pass (**kwargs)
    if(log.history()):
        vbar value YScrollValue("chatlog"):
            xpos 1000
1564 Studio, an indie studio dedicated to developing mystery VNs!
Follow us on Twitter for updates on our projects!

Image

Check out our current project, just released on PC, Android, Switch, XBox ONE/Series S/X and PS4/5!
Also available in Spanish, English, French and Japanese!

Image

tornsoul
Regular
Posts: 29
Joined: Sat Jun 19, 2021 7:32 pm
Contact:

Re: Is there a way to know in which language is the game right now?

#7 Post by tornsoul »

Your viewport has no dimension or position?

Are those screenshots of the whole screen? or partials?

It looks to me like the texts are both centered around the same point - which isn't far from the right edge of the center blue area in your widget.
Ie. the middle of each text lines up with each other.
How on earth that has become your center point I don't know.

If those screenshots are partials - I would guess the viewport takes up the whole screen?
In which case xalign 0.5 would be the middle of the screen.
And if your widget isn't centered on the screen then of course the text won't be either.
(the above might be obvious to you - Not sure about your skill level...)


There is also some wonkyness with your indentation of vbox and your last "if" - Might work as intended, I'm just unsure what that would be - It just caught my eye is all.
Do you really want to show that vbox even if there is no log.history?

and that last "if" looks as if it should be indented one more time (to align with the other if) - and why isn't it just an "else"?

User avatar
Karrion
Regular
Posts: 73
Joined: Fri Jan 18, 2019 8:33 pm
Projects: Murder on the Marine Express
Organization: 1564 Studio
itch: 1564-studio
Contact:

Re: Is there a way to know in which language is the game right now?

#8 Post by Karrion »

The code is mostly taken from here: https://poorlifechoices.itch.io/renpy-chatlog and I tinkered with it a bit to adjust to what we want, so maybe I'm missing something there that moved the center point? I tried to xanchor to the center (game's resolution es 1920x1080 so 960), but that doesn't work either. The screenshots are the full screen of the game, but not the full screen of the pc (it's windowed, i just took the part of the game).
1564 Studio, an indie studio dedicated to developing mystery VNs!
Follow us on Twitter for updates on our projects!

Image

Check out our current project, just released on PC, Android, Switch, XBox ONE/Series S/X and PS4/5!
Also available in Spanish, English, French and Japanese!

Image

User avatar
Karrion
Regular
Posts: 73
Joined: Fri Jan 18, 2019 8:33 pm
Projects: Murder on the Marine Express
Organization: 1564 Studio
itch: 1564-studio
Contact:

Re: Is there a way to know in which language is the game right now?

#9 Post by Karrion »

Ok, so apparently I was putting an xpos and ypos when calling the screen, now the message is shown as expected both in spanish and english, but now the chat looks like this and don't know where to put the xpos and ypos to move it:

https://i.imgur.com/uBNUTeR.png
1564 Studio, an indie studio dedicated to developing mystery VNs!
Follow us on Twitter for updates on our projects!

Image

Check out our current project, just released on PC, Android, Switch, XBox ONE/Series S/X and PS4/5!
Also available in Spanish, English, French and Japanese!

Image


Post Reply

Who is online

Users browsing this forum: No registered users