No, it can't work for simple words, you have to translate the whole line of dialog.
As for the code you posted for words replacement, I don't recommend you, or anyone else, to use it. It works blindly, so unless you really know what you do and how to write strong RegEx, it will change a lots of things you don't want to see changed.
For the example, lets say it works on the other way, incest->none incest, and you want to replace "mom" by "laura". You'll use this code, and the player will see things like, "one lauraent, I finish what I'm doing and come help you." (because of "
moment" ).
Even if you have strong RegEx, it's still not the best option. There's more variety on a way than on the other. A none incest line can be "I can't, it's Laura", but the incest line can't be "I can't, it's mom". It should be something like "I can't, it's my mom", or even better, "I can't, it's my mother". But in the same time, "Laura, come here please", can be "Mom, come here please".
What you can do is to create an object for each character, and you use it to perform the replacement in real time.
Code:
class Names( object ):
def __init__( self, **kwargs ):
for k, v in kwargs:
setattr( self, k, v )
setattr( self, k.capitalize(), v.capitalize() )
[incest way]
mom.names = Names( formal="mother", informal="mom", fullFormal="my mother" )
[none incest way]
mom.names = Names( formal="teacher", informal="laura", fullFormal="my teacher" )
[...]
"I can't, she's [mom.names.fullFormal] !"
"[mom.names.Informal], come here please."
And you'll have :
"I can't, she's my teacher !"
"Laura, come here please."
or
"I can't, she's my mother !"
"Mom, come here please."
It give you more flexibility and control over what you want to display and on how it's changed. Plus side, put this on a rpy file, at "init 99 python" and this file will be the only change you need to patch your game.
The only limitation of this method is that you can't have names defined by the user. But it's because I'm lazy and will not write a full class as just an example. If you want I can write it to handle this as well. It's easy and I already have a code reusable for this somewhere.
For me, it's definitively the best of all the options because it's the simplest of them all. You have full control over the change, it's soft patching (put the rpy file, it's an incest game, remove the rpy file it's a none incest game), it's extendable and once you've done the configuration (created the object for each character) you don't have to think about it, just use the right field from the right object.