Most of the plugins here are made by B3 users and the authors may not visit frequently. If you need support for plugins or if questions remain unanswered, you will have to contact the author directly. Read the full Support Disclaimer here
NOTE: Do not attach plugins to your forumtopics! Attachements are periodically removed by maintenance tasks. Upload your plugins to our Downloads section instead!

You are here: Big Brother Bot ForumAdd-OnsPlugins DiscussionPlugin Releases! (Moderator: MordyT)Translators plugin
Pages: [1] 2   Go Down
  Print  
Author Topic: Translators plugin  (Read 2897 times) Bookmark and Share
Jr. Member
**
OS: Linux
Type: --No B3 installed--
Gameservers: UrT
Posts: 10
Offline Offline
« on: August 26, 2010, 02:02:04 AM »

Description:
This plugin allows players to translate text on the chat without even leaving their favorite game server. It's dedicated to people who are not confident with foreign languages, who don't want to lose time into translation to communicate or those who just want to have fun with foreign friends.

Features:
- translates text from and to any language supported by Google Translate.
- automatic chat translation. If a chat line is detected to be written in a "foreign" language, the text is translated and dislplayed.



Commands:
- !trans [src lang|dest lang] <sentence> : translates a sentence (use @trans to make the translation available to everyone).
- !translast : translates the latest available sentence from the chat.
- !transauto : enables/disables automatic translation feature.
- !transversion : displays plugin version.

How to use !trans:
The source language parameter is optional and should be used if language auto-detection fails. The destination language parameter is optional, use it if you don't want to translate into the default language.
- example 1, language auto-detection, default destination language :
!trans Sentence to translate
- example 2, language auto-detection, given destination langyage :
!trans |nl Sentence to translate
- example 3, given source language, default destination language :
!trans fr| Phrase a traduire
- example 4, given source and destination languages :
!trans fr|de Phrase a traduire

Installation:
- copy the directory "xgoogle" into your b3 root directory.
- copy the file "xjson.py" into your b3 root directory (optional if you use geowelcome plugin).
- copy the file translators.py into b3/extplugins.
- copy the file translators.xml into b3/extplugins/conf.
- add the following line into the plugins section in b3.xml : <plugin name="translators" config="@b3/extplugins/conf/translators.xml"/>

Configuration file:
- settings/autotranslation : activates automatic translation at startup.
- settings/autothreshold : sets the minimum sentence size required to translate it automatically (also used by !translast).
- settings/translatecmd : if set to 1, also translates chat lines starting with a B3 command.
- settings/defaultsrclang : sets default source language (optional).
- settings/defaultdestlang : sets default destination language.

Notes:
- translations may be inaccurate, use it at your own risk.
- for a list of available languages see http://translate.google.com and http://www.google.com/cse/docs/resultsxml.html#countryCodes for country codes.
- special characters like accented letters or cyrillic are not displayed.
- the plugin name is Translators, with a final 's'.
- keep in mind that this plugin produces additional network traffic to get the results from Google Translate.
- the translation function can be used in other plugins. Just load the Translators plugin first :
Code:
    self._translators = self.console.getPlugin('translators')
     if not self._translators:
         self.debug('Could not find Translators plugin')
 Then use translate() method within try-except block :
Code:
    try:
        msg = self._translators.translate('Sentence you want to translate')
     except:
        pass
 Same language parameters as the !trans command can be set, for example translate('|es Sentence you want to translate').
- this plugin can be used as a command-line translator. Add your B3 directory path to the PYTHONPATH shell variable, then run the plugin by typing python translators.py.

Download link:
http://www.bigbrotherbot.net/forums/downloads/?sa=view;down=86

Thanks:
- Google Translate : http://translate.google.com
- xgoogle python library by Peteris Krumins: http://www.catonmat.net/blog/python-library-for-google-translate/
- DSWP community (http://www.dswp.de) and other Urban Terror players for testing.
« Last Edit: August 26, 2010, 02:07:46 AM by SvaRoX » Logged

XLRstats dev.
Dev. Team
*
OS: Linux
Type: Home user
Gameservers: COD5, COD7, BF3
Posts: 909
Offline Offline
WWW
Support Specialty: XLRstats webfront
« Reply #1 on: August 26, 2010, 02:59:56 AM »

A very nice plugin idea. Good job!  Smiley
Logged

Jr. Member
**
OS: Windows
Type: Home user
Gameservers: UrT
Posts: 44
Offline Offline
WWW
« Reply #2 on: August 26, 2010, 03:31:33 AM »

very very very nice svarox
Logged
B3 Contrib/Support
*
OS: Linux
Type: Home user
Gameservers: Over see 25 URT servers / B3 servers (not all mine)
Posts: 339
Offline Offline
WWW
« Reply #3 on: August 26, 2010, 05:35:31 PM »

Plug-in of the year award ?
Logged
[ www.xlrstats.com ]
Project Lead
*
OS: Linux
Type: Owner dedicated server(s)
Gameservers: CoD, CoD2, CoD5, UrT
Posts: 2007
Offline Offline
WWW
Support Specialty: B3-Core, CoD/UrT/WoP/ETPro parsers, Plugin development
« Reply #4 on: August 27, 2010, 01:36:56 AM »

This plugin requires extra libraries to function properly. The B3 windows binaries do not hold these binaries by default. It would be great if we could include the libraries to our main B3 distribution, but it would need some reorganisation of you current plugin.

We would place the xgoogle library in: b3/lib/xgoogle/
and the xjson.py in: b3/lib/

This keeps our core code properly seperated from all included libs and makes library maintenance easier.

Please make the proper changes to the plugin and we will include the libs in our main B3 distribution.
Logged

Former Dev. (senate)
*****
OS: Linux
Type: Owner dedicated server(s)
Gameservers: OpenArena
Posts: 258
Offline Offline
« Reply #5 on: August 27, 2010, 10:48:05 AM »

Great. Well done.

The only thing to verify is : is google ok with that ? Normally, the Google disclaimer prohibit any automatic usage of their services. So better lower down the amount of traffic to a minimum to avoid problems...
« Last Edit: August 27, 2010, 11:09:18 AM by grosbedo » Logged
Former Dev. (senate)
*****
OS: Linux
Type: Owner dedicated server(s)
Gameservers: OpenArena
Posts: 258
Offline Offline
« Reply #6 on: August 27, 2010, 11:59:09 AM »

I tested it on OpenArena, works well, should work for any q3a based game.

Just a suggestion : Ive noticed that !translast doesn't translate the very last chat message from all players, but the last message of the player requesting !translast. Would it be possible to switch the behaviour, so !translast effectively translate the very last message from all players ?
Logged
Jr. Member
**
OS: Linux
Type: --No B3 installed--
Gameservers: UrT
Posts: 10
Offline Offline
« Reply #7 on: August 28, 2010, 03:27:44 AM »

Thanks guys Smiley

@xlr8or:
Oops sorry I haven't tested the plugin on B3 for Windows, I will make the modifications and update it soon. Great if you add it in the distribution =) By the way, is it a rule to also use the lib directory for any third party plugins or is it just for special cases like included plugin ?

@grosbedo:
Good point mentioning the rights of using the service. In fact I also had Google's point of view in mind when I wrote the warning about traffic increase in the notes. Actually the python library is based on the Language API, which is dedicated to "semi automatic" translations from scripts, so I guess that kind of use is tolerated by Google for this service...
About !translast : it should translate anyone's chat. Did you make sure the sentence had more characters than the "autothreshold" setting ? It also doesn't translate team chat yet, I will change that in the upcoming version.
Logged
Former Dev. (senate)
*****
OS: Linux
Type: Owner dedicated server(s)
Gameservers: OpenArena
Posts: 258
Offline Offline
« Reply #8 on: August 28, 2010, 04:30:15 AM »

Good point mentioning the rights of using the service. In fact I also had Google's point of view in mind when I wrote the warning about traffic increase in the notes. Actually the python library is based on the Language API, which is dedicated to "semi automatic" translations from scripts, so I guess that kind of use is tolerated by Google for this service...

Yes but game servers are another thing than a standard desktop application. Maybe there should be a limit, like 3 translations in a row and then you need to wait ?

For the moment I don't think this will be a problem but in the future it might be. Does your script can react if google block the access ? You know, after a certain amount of tries, Google asks for a CAPTCHA to be able to continue to use their services...

About !translast : it should translate anyone's chat. Did you make sure the sentence had more characters than the "autothreshold" setting ? It also doesn't translate team chat yet, I will change that in the upcoming version.

No, indeed, I didn't see the little mention, my bad. Thank you very much, it's working greatly now Smiley
Logged
Former Dev. (senate)
*****
OS: Linux
Type: Owner dedicated server(s)
Gameservers: OpenArena
Posts: 258
Offline Offline
« Reply #9 on: August 28, 2010, 05:12:26 AM »

Just a note about ergonomy : when I use !translast, people tend to get confused and, when they try to mimic me, they type !translate.

So Ive added !translate as an alias for !trans, and !lasttrans as an alias for !translast :

Code:
    <settings name="commands">
        <set name="trans-translate">0</set>
        <set name="translast-lasttrans">0</set>
        <set name="transauto">2</set>
        <set name="transversion">20</set>
    </settings>
Logged
Full Member
***
OS: Windows
Type: Renting Server with B3
Gameservers: UrT
Posts: 123
Offline Offline
« Reply #10 on: September 03, 2010, 09:39:46 AM »

this plugin doesn't work and console shut down.
it's possible i do a mistake...

here's my b3.log

Code:
100903 19:36:55 BOT    Loading Plugin #22 translators [D:\Immagini dischi\Urban Terror\b3-1.3.3\b3-1.3.3\b3\extplugins\conf\translators.xml]
100903 19:36:55 INFO Could not load built in plugin translators (No module named translators)
100903 19:36:55 INFO trying external plugin directory : D:\Immagini dischi\Urban Terror\b3-1.3.3\b3-1.3.3\b3\extplugins
100903 19:36:55 CRITICAL Error loading plugin: No module named xgoogle.translate
Traceback (most recent call last):
  File "D:\Immagini dischi\Urban Terror\b3-1.3.3\b3-1.3.3\b3\parser.py", line 497, in loadPlugins
    pluginModule = self.pluginImport(p)
  File "D:\Immagini dischi\Urban Terror\b3-1.3.3\b3-1.3.3\b3\parser.py", line 565, in pluginImport
    return imp.load_module(name, fp, pathname, description)
  File "D:\Immagini dischi\Urban Terror\b3-1.3.3\b3-1.3.3\b3\extplugins\translators.py", line 23, in <module>
    from xgoogle.translate import Translator, TranslationError, LanguageDetector, DetectionError
ImportError: No module named xgoogle.translate
100903 19:36:55 INFO STDOUT 220
100903 19:36:55 INFO STDOUT


can anyone help me?
Logged
Former Dev. (senate)
*****
OS: Linux
Type: Owner dedicated server(s)
Gameservers: OpenArena
Posts: 258
Offline Offline
« Reply #11 on: September 03, 2010, 01:00:14 PM »

You're missing the necessary additional libraries, or you misplaced them.

You must copy the folder xgoogle and the file xjson.py from the archive, to your b3 root folder (in the same folder as b3_run.py and setup.py). Then, you have to restart B3, and it should work.

Note : if you are using B3 on a Windows OS, you cannot use this plugin with the installer package of B3, you will have to wait for the next version of B3.
Logged
Full Member
***
OS: Windows
Type: Renting Server with B3
Gameservers: UrT
Posts: 123
Offline Offline
« Reply #12 on: September 07, 2010, 02:16:17 AM »

You're missing the necessary additional libraries, or you misplaced them.

You must copy the folder xgoogle and the file xjson.py from the archive, to your b3 root folder (in the same folder as b3_run.py and setup.py). Then, you have to restart B3, and it should work.

Note : if you are using B3 on a Windows OS, you cannot use this plugin with the installer package of B3, you will have to wait for the next version of B3.

allright. very well, your suggestion is okay!
plugin with xgoogle and xjson.py now works correctly.
thank you so much!
Logged
Jr. Member
**
OS: Linux
Type: Owner dedicated server(s)
Gameservers: UrT
Posts: 20
Offline Offline
« Reply #13 on: September 10, 2010, 12:03:04 AM »

@SvaRoX - Really nice, even if I did not have the chance to use it yet, I'm going to install to all my servers right now, it is really a good idea !!

 Grin Grin what about going a little forward Huh??

my foolish mind asked me and I do the same to you Cheesy Tongue Cheesy

do you think it could be possible to connect this plugin with a sort of geolocalization mchanism so that when activating the automatic translation it convert sentences from each other at least into the standard server's language ...


MsK
Logged

Former Dev. (senate)
*****
OS: Linux
Type: Owner dedicated server(s)
Gameservers: OpenArena
Posts: 258
Offline Offline
« Reply #14 on: September 10, 2010, 02:09:45 AM »

do you think it could be possible to connect this plugin with a sort of geolocalization mchanism so that when activating the automatic translation it convert sentences from each other at least into the standard server's language ...

I think it should be possible and not too hard using the functions provided by the CountryFilter plugin. It would be a good idea indeed, people would get the auto translation directly in their language instead of the default English one.
Logged
Tags:
Pages: [1] 2   Go Up
  Print  
 
Jump to:  


Rate this page +1 at Google Search


SimplePortal 2.3.1 © 2008-2009, SimplePortal