MegBot icon indicating copy to clipboard operation
MegBot copied to clipboard

Multiple language support

Open tsyesika opened this issue 12 years ago • 2 comments

It'd be cool if we could have support for multiple languages in megbot. We have two options, we can do it per channel/network/plugin or whatever and/or we could do it per user i.e. the user will set the language they speak and if they do for example

!weather

It'd return in the language they speak.

They is also this tying into #19 because a speaker of say german will want the german word for weather (wetter) so !wetter.

tsyesika avatar Jan 22 '13 10:01 tsyesika

So first, the aliases are completely being handled in #19

Secondly there's a few things we need to remember when doing this:

By far the easiest is:

Channel.send("Hello")

This you would want it to look up behind the scenes what language the user wants it in (whoever it's going to or what language the bot is set or etc...) Once it's done we want to translate the string (if needed) and take the translated string and pass it through to the Core/privmsg.py how it currently is now.

It gets a bit more complicated when you get

Channel.send("Your name is %s" % name)

This you have to think, the translation string won't have the possible amount of names ever. There are a few ways we could do this. The most complicated would be to use some form of parsing probably regex to take the translated string which would have the %s in and find the values of these in the string we got given and try and move them across into the newly translated one.

The second and most preferable to me would be to have a call which you pass the arguments in and the string formatting is done later (I think this is also the standard way of doing it) this would be:

Channel.send("Your name is %s", name) 

What would happen here is we look up the string "Your name is %s" and get the translation (the translation containing the %s" we then do the string formatting so translated_string = translated_string % name subbing it in just fine.

As a translator myself however I know of problems. I don't really have solutions but I think they need to be discussed:

  • Number bases (we work in base 10, not all languages do)
  • Different ways of doing things depending on language (e.g. commonly it's not just one singular and one plural, there can be many).
  • parameters to plugins, do we translate? - how? the weather plugin, if i'm in welsh and write Rhydychen instead of Oxford, should be handle that, would the plugin know. It's a difficult situation.

tsyesika avatar Mar 09 '13 02:03 tsyesika

We have now changed how the Channel.send, channel.notice, etc... methods work. We now have:

Channel.send("Your name is %s", name)
Channel.notice("You have %s new messages", message_count)

etc... Any method like this which isn't already converted, should be.

tsyesika avatar Apr 18 '13 10:04 tsyesika