XaiJu
Renpytom
Renpytom

patreon


Python Tricks #1

Since right now I'm working on porting Ren'Py to the latest versions of Android, this month's article is a couple of small Python snippets that I've come up with in support of projects lately. Since these have the potential to simplify your projects, I thought I'd write them up and post them. I hope you find some of these examples useful, and thank you for your support.


Python Tricks #1

Comments

There are two ways you could do this. One would be to use [he!t] to invoke Ren'Py's translation system. But I think a better way would be to use the __ (double-underscore) function, which translates the string it gets as an argument. If you changed the __unicode__ function to return __(self.he), it would return the translated string, and you could just write [he] again. You'd also want to use _("he"), _("she"), etc to mark the strings as translatable in the first place.

Renpytom

How does this work with translations?

Bruni Multimedia

I'll be honest, "they" is a pretty tough one. My guess as to the best way to do it would be to have variables like "[he_is]" that would be "he is", "she is", or "they are" as appropriate. Well, the best way would be for me to clean up the generative text framework I made a few years ago and post it. But it's so dodgy, and you needed to be on the ball to use it. Maybe something like a text hook that catches "they is" and fixes is would be a simple and correct approach. I'm thinking generative text and a good solution to the pronoun issue would be a full article, and with the android deadline tonight (not gonna make it), I didn't have time to write it.

Renpytom

This is great! Especially the pronoun bit. I'm glad they was included! I'll have to do some more thinking on how to change the verb connected to "they"

noeinan

Very cool tricks...one thing that would be a good thing to add to the pronoun picker discussion is about how to deal with verbs. Say the sentence using male pronouns would be "[He] is sitting in front of you." That will be fine for he and she...but they would be "are sitting" rather than is sitting. And also, "He sits" and "She sits" but "They sit." So...are there ways your cool snippets might be utilized to deal with the verb question as well?

TrooperSJP


More Creators