SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 03/12/2013, 12:58 PM   #1
Bombo
Huge Clucker
 
Bombo's Avatar
 
Join Date: Jun 2012
Posts: 285
Reputation: 76
Default Automatic chat translator

Automatic chat translator

Author: Bombo
Version: 1.0.0

PHP Code:
//Clean the translation cache.
//Run it once before every sequence of the cached translations (cached translations with the same in_text).
native new_translate();

//Translate without caching (slow).
//out_text[]        - translation result
//in_text[]        - input text
//in_lang_from[]    - input language (must be:"en","it", "de", "ru" and etc.). 2 chars only!
//in_lang_to[]        - output language (must be:"en","it", "de", "ru" and etc.). 2 chars only!
native translate(out_text[], in_text[], in_lang_from[], in_lang_to[], size=sizeof out_text);

//Translate with caching (fast).
//Cache a translation to each language. So, the next run of this function with the same in_lang_from
//and in_lang_to will take translation from cache.
//out_text[]        - translation result
//in_text[]        - input text
//in_lang_from[]    - input language (must be:"en","it", "de", "ru" and etc.). 2 chars only!
//in_lang_to[]        - output language (must be:"en","it", "de", "ru" and etc.). 2 chars only!
//fnick            - if 1, don't translate players's nicks.
native translate_cached(out_text[], in_text[], in_lang_from[], in_lang_to[], fnick=1size=sizeof out_text);

//Translate by playerid with caching.
//Cache a translation to each language.
//out_text[]        - translation result
//in_text[]        - input text
//in_playerid_from    - ID of the Player1
//in_playerid_to    - ID of the Player2
//fnick            - if 1, don't translate players's nicks.
native translate_id(out_text[], in_text[], in_playerid_fromin_playerid_tofnick=1size=sizeof out_text);

//Translate with caching. Do not translate nicks.
//An old function. Don't use it, please.
native translate_nick(out_text[], in_text[], in_lang_from[], in_lang_to[], size=sizeof out_text);

//Get country code ("GB", "IT" etc.)
//It's such a locating.
//in_ip_addr[]        - IP address
//out_lang[]        - the result (buffer >= 3 chars)
native language(in_ip_addr[], out_lang[]);

//Set player language.
//n_playerid        - playerid
//in_lang[]        - language (2 chars: "en", "ru", "ro" etc.)
native setplayerlang(in_playeridin_lang[]);

//Get player language.
//n_playerid        - playerid
//out_lang[]        - result (buffer >= 3 chars)
native getplayerlang(in_playeridout_lang[]);

//Set player country.
//n_playerid        - playerid
//in_land[]        - country code (2 chars: "GB", "IT" etc.)
native setplayerland(in_playeridin_land[]);

//Get player country from memory.
//n_playerid        - playerid
//out_land[]        - result (buffer >= 3 chars)
native getplayerland(in_playeridout_land[]);

//Add player.
//in_nick[]        - nick
native add_nick(in_nick[]);

//Add player. Set nick, playerid and IP address
//in_nick[]        - nick
//in_playerid        - playerid
//in_ip_addr[]        - IP address (for example "55.66.77.123")
native add_nick_id_ip(in_nick[], in_playeridin_ip_addr[]);

//Del player.
//in_nick[]        - nick
native del_nick(in_nick[]);

//Del all players from temporary tables of the plugin.
native del_all_players();

//Initialization of imes file.
//imes is a file with the multilanguage strings for localisation.
//in_filename[]        - filename
native init_ifile(in_filename[]);

//Close imes file.
native close_ifile();

//Get a string from the imes file.
//out_text[]        - result
//in_name[]        - the name of a string
//in_language[]        - local language code (2 chars: "en", "tr" etc.)
native imessage(out_text[], in_name[], in_language[], size=sizeof out_text); 
1. Copy the translator.dll or the translator.so to your plugins folder.
2. Copy the SAMPle.amx to your filterscripts folder.
3. Copy the imes.txt file to the server folder.
4. Add the "SAMPle" to filterscripts of your server.cfg file (you must set it to the end of the filterscripts list!).
5. Add the "translator" or "translator.so" to plugins in your server.cfg file.
6. Register yourself on the http://www.bing.com/developers/appids.aspx and get your appId (it's such a key).
7. Copy your appId to the ms_translate_key.txt file.
8. Move the ms_translate_key.txt file to the server folder.

WARNING: the default appId (6635D742380CF583FEE16FF83E80BC8238F166E3) is only for testing! It will be void soon. Don't use it anywhere except the test, please.

This plugin contains a built-in module of locating by IP.

Commands:
/translator on - admin only
/translator off - admin only
/help
/lang - choose your language
/slang - choose language for translating test
/land - list of players
/sinhro on - show you the original messages from other players
/sinhro off - don't show you the original messages from other players

The result:


Test server: samp://botinform.asuscomm.com:7797
Attached Files
File Type: zip translator.zip (1.04 MB, 787 views)
__________________
[Tool/Web/Other] SA:MP multiloader
[Plugin] Automatic chat translator
[GameMode] DayZ+ [0.3z]
[Plugin] imessage - fast multilanguage strings
[Tool/Web/Other] player search service

Last edited by Bombo; 03/10/2017 at 12:05 AM. Reason: description upd
Bombo is offline   Reply With Quote
Old 03/12/2013, 01:43 PM   #2
newbienoob
High-roller
 
newbienoob's Avatar
 
Join Date: Jan 2012
Location: Follow the moaning coming from your parents' bedroom
Posts: 1,562
Reputation: 265
Default Re: Automatic chat translator

Russians
__________________
Help me, please /a chat
newbienoob is offline   Reply With Quote
Old 03/12/2013, 01:44 PM   #3
Baboon
High-roller
 
Baboon's Avatar
 
Join Date: Nov 2010
Location: The Netherlands
Posts: 1,593
Reputation: 315
Default Re: Automatic chat translator

Will it fail translate from English to English?
Anyway, looking interesting.
I would add an option though, so people can disable the translation processes.
__________________
Baboon is offline   Reply With Quote
Old 03/12/2013, 02:03 PM   #4
Kindred
High-roller
 
Join Date: Aug 2011
Posts: 1,649
Reputation: 504
Default Re: Automatic chat translator

Really handy script. Well done.
Kindred is offline   Reply With Quote
Old 03/12/2013, 02:21 PM   #5
Bombo
Huge Clucker
 
Bombo's Avatar
 
Join Date: Jun 2012
Posts: 285
Reputation: 76
Default Re: Automatic chat translator

Quote:
Originally Posted by Strawhats View Post
Will it fail translate from English to English?
Anyway, looking interesting.
I would add an option though, so people can disable the translation processes.
1. No! It will not translate nicknames either.
2. I've added such a command:
/translator on
/translator off
for admins only.
__________________
[Tool/Web/Other] SA:MP multiloader
[Plugin] Automatic chat translator
[GameMode] DayZ+ [0.3z]
[Plugin] imessage - fast multilanguage strings
[Tool/Web/Other] player search service
Bombo is offline   Reply With Quote
Old 03/12/2013, 02:37 PM   #6
iZN
High-roller
 
Join Date: Jun 2010
Posts: 2,444
Reputation: 569
Default Re: Automatic chat translator

Looks good but if you don't mind can you upload the source file of that filterscript? You didn't even mentioned the natives of the plugin, mind giving some more information about it?
__________________
iZN is offline   Reply With Quote
Old 03/12/2013, 02:51 PM   #7
Bombo
Huge Clucker
 
Bombo's Avatar
 
Join Date: Jun 2012
Posts: 285
Reputation: 76
Default Re: Automatic chat translator

Quote:
Originally Posted by iZN View Post
Looks good but if you don't mind can you upload the source file of that filterscript?
This source is in the translator.zip

Quote:
Originally Posted by iZN View Post
You didn't even mentioned the natives of the plugin, mind giving some more information about it?
Ok. But not now.
__________________
[Tool/Web/Other] SA:MP multiloader
[Plugin] Automatic chat translator
[GameMode] DayZ+ [0.3z]
[Plugin] imessage - fast multilanguage strings
[Tool/Web/Other] player search service
Bombo is offline   Reply With Quote
Old 03/12/2013, 05:15 PM   #8
Biesmen
High-roller
 
Biesmen's Avatar
 
Join Date: May 2009
Posts: 1,884
Reputation: 665
Default Re: Automatic chat translator

What is that AppID function good for?
Biesmen is offline   Reply With Quote
Old 03/12/2013, 05:34 PM   #9
Bombo
Huge Clucker
 
Bombo's Avatar
 
Join Date: Jun 2012
Posts: 285
Reputation: 76
Default Re: Automatic chat translator

Quote:
Originally Posted by Biesmen View Post
What is that AppID function good for?
It's a key for the api.microsofttranslator.com

Does anybody know free online translator with AJAX or JSON interface?
__________________
[Tool/Web/Other] SA:MP multiloader
[Plugin] Automatic chat translator
[GameMode] DayZ+ [0.3z]
[Plugin] imessage - fast multilanguage strings
[Tool/Web/Other] player search service
Bombo is offline   Reply With Quote
Old 03/12/2013, 09:48 PM   #10
Memoryz
Gangsta
 
Join Date: Dec 2008
Posts: 746
Reputation: 26
Default Re: Automatic chat translator

This is extremely useful, will be trying it out in conjunction with IP-based locations to determine which language to show them.
Memoryz is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
automatic chat Aloushi Scripting Help 5 07/02/2012 12:11 PM
In Game Translator? fie Help Archive 2 02/08/2011 01:26 PM
You can disable the automatic parachute and automatic shotgun in lspd cars? CTCCoco Help Archive 1 05/02/2010 05:08 PM
IN GAME TRANSLATOR teamsheetz Help Archive 10 12/07/2009 02:09 AM
Automatic open chat box Dujma Help Archive 18 13/03/2009 07:03 PM


All times are GMT. The time now is 03:30 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.