Having RTL enabled causes {w} tag to crash game

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
User avatar
hassohappa
Regular
Posts: 33
Joined: Thu Oct 22, 2015 8:51 pm
Tumblr: me-patra
Contact:

Having RTL enabled causes {w} tag to crash game

#1 Post by hassohappa »

I've been trying to implement a right-to-left language translation (Farsi) for my game, and added this.

renpy.config.rtl = True

However, it seems that as long as this is true, the {w} tag causes an error in all languages (Farsi, English, etc):

Code: Select all

While running game code:
  File "game/1_diya.rpy", line 169, in script
    Hayden "I'm right here!{w=0.35} The evil dragon!"
TypeError: Argument 's' has incorrect type (expected unicode, got str)
The traceback is quite long, but the culprit can be found inside rtl_paragraph:

Code: Select all

  File "C:\Users\Brianna\Documents\Programs\renpy-7.3.5-sdk\renpy\text\text.py", line 612, in __init__
    p, rtl = self.rtl_paragraph(p)
  File "C:\Users\Brianna\Documents\Programs\renpy-7.3.5-sdk\renpy\text\text.py", line 1205, in rtl_paragraph
    s, direction = log2vis(s, direction)
TypeError: Argument 's' has incorrect type (expected unicode, got str)

Windows-8-6.2.9200
Ren'Py 7.3.5.606
This happens for the plain {w} as well. Luckily, the other text tags like slow/fast, italics, size, seem to work fine.

Is this a known bug, or is there a workaround for this? Otherwise, I'll have to manually remove the {w} tags from the game and all its translations, which is a lot of work...

rames44
Veteran
Posts: 233
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: Having RTL enabled causes {w} tag to crash game

#2 Post by rames44 »

I would suggest that you file a bug report over on GitHub describing this - I'm betting PyTom will get it fixed reasonably quickly, and/or perhaps give you a workaround.

User avatar
hassohappa
Regular
Posts: 33
Joined: Thu Oct 22, 2015 8:51 pm
Tumblr: me-patra
Contact:

Re: Having RTL enabled causes {w} tag to crash game

#3 Post by hassohappa »

Good idea! For anyone from the future also encountering the issue, I've filed the bug report here: https://github.com/renpy/renpy/issues/2298

User avatar
hassohappa
Regular
Posts: 33
Joined: Thu Oct 22, 2015 8:51 pm
Tumblr: me-patra
Contact:

Re: Having RTL enabled causes {w} tag to crash game

#4 Post by hassohappa »

Since it's been a week and no one's responded to the bug, here is my very clunky workaround.

1. Delete all {w} tags from the rtl language translations (in my case, just Farsi). This is tedious and will cause the waits not to work in those translations, but the waits will still work in other languages.

2. When the player opens the game for the first time, set config.rtl to True if they pick a rtl language.

Code: Select all

label splashscreen:
    if not persistent.language_selected:
        menu:
            "English":
                $renpy.change_language (None)
            "{font=traditional_chinese.ttf}中文{/font}":
                $renpy.change_language ("traditional_chinese")
            "{font=homa.ttf}فارسی{/font}":
                $renpy.change_language ("farsi")
                $renpy.config.rtl = True
        $ persistent.language_selected = True
But if they pick Farsi and later change the language to, say, English in the settings, rtl will still be on and cause the exception at {w} in the English version. Hence this next part...

3. In my init python block, I made this function that will turn rtl on or off:

Code: Select all

    def rtlConfig(rtlState):
        if rtlState:
            renpy.config.rtl = True
        else:
            renpy.config.rtl = False
4. Now call that function when picking a language from the settings menu.

Code: Select all

label _("Language")
                    textbutton _("English") action [Language(None), Function(rtlConfig, False) ]
                    textbutton _("{font=traditional_chinese.ttf}{size=30}中文{/size}{/font}") action [Language("traditional_chinese"), Function(rtlConfig, False) ]
                    textbutton _("{font=homa.ttf}{size=30}فارسی{/size}{/font}") action [Language("farsi"),  Function(rtlConfig, True)]
I'm sure there's a better way to do this (is there a way to set config values straight from buttons?)... But hey, at least I don't need to delete the {w} tags in all languages now.

Post Reply

Who is online

Users browsing this forum: No registered users