Raised This Month: $51 Target: $400
 12% 

Translator Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
headline
SourceMod Moderator
Join Date: Mar 2015
Old 06-20-2017 , 10:49   Translator Plugin
Reply With Quote #1

I've laid some groundwork for this plugin idea, but have no interest in finishing it so here's my offer to you. Basically, I want gameservers to be engaging for all players across all language barriers. This is how I think this can be accomplished.

Description:
A plugin which translates all text chat messages to & from a specific client who doesn't speak the server's main language. There are multiple ways this can be formatted, but here's what I was thinking

(Me as a German speaker in an English server.)
Code:
Some Player: Hey, Headline. How old are you?
Some Player {TRANSLATED FOR YOU}: Hallo, Headline. Wie alt bist du?
Headline: Ich bin 20
Headline {TRANSLATED FOR OTHERS}: I am 20
What I've done:

I've made a small php script which uses Google Translate's API hosted @ http://headlinedev.xyz/translate/translate.php
With get parameters of 'input' and 'target' where 'target' is the target language (spanish is 'es', for example).


Here's some code for you that I mocked up with an example request. There are some challenges that'd need to be worked out, but that's up to you to solve.

PHP Code:
#include <sdktools>
#include <SteamWorks>

public void Example()
{
    
Handle request CreateRequest("Hello, My name is \"headline\"""es"0);
    
SteamWorks_SendHTTPRequest(request);
}

Handle CreateRequest(char[] inputchar[] targetint client)
{
    
Handle request SteamWorks_CreateHTTPRequest(k_EHTTPMethodGET"http://www.headlinedev.xyz/translate/translate.php");
    
SteamWorks_SetHTTPRequestGetOrPostParameter(request"input"input);
    
SteamWorks_SetHTTPRequestGetOrPostParameter(request"target"target);
    
    
SteamWorks_SetHTTPRequestContextValue(requestGetClientUserId(client));
    
SteamWorks_SetHTTPCallbacks(requestCallback_OnHTTPResponse);
    return 
request;
}

public 
int Callback_OnHTTPResponse(Handle requestbool bFailurebool bRequestSuccessfulEHTTPStatusCode eStatusCodeint userid)
{
    if (!
bRequestSuccessful || eStatusCode != k_EHTTPStatusCode200OK)
    {        
        return;
    }

    
int iBufferSize;
    
SteamWorks_GetHTTPResponseBodySize(requestiBufferSize);
    
    
char[] result = new char[iBufferSize];
    
SteamWorks_GetHTTPResponseBodyData(requestresultiBufferSize);
    
delete request;

    
    
// do something with result


Last edited by headline; 06-20-2017 at 10:54.
headline is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 06-20-2017 , 12:01   Re: Translator Plugin
Reply With Quote #2

This seems a very usefull tool. You could release the php script too for host yourself? Probably I will make a public plugin with this since I have spanish and english people in the same servers.
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
headline
SourceMod Moderator
Join Date: Mar 2015
Old 06-20-2017 , 12:24   Re: Translator Plugin
Reply With Quote #3

Quote:
Originally Posted by Franc1sco View Post
This seems a very usefull tool. You could release the php script too for host yourself? Probably I will make a public plugin with this since I have spanish and english people in the same servers.
Im alright with releasing this php script, but under the agreement that if you make this plugin it will be released publicly
headline is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 06-20-2017 , 13:26   Re: Translator Plugin
Reply With Quote #4

Quote:
Originally Posted by Headline View Post
Im alright with releasing this php script, but under the agreement that if you make this plugin it will be released publicly
Yes, that is the intention. I would like to see a lot of servers (specially jailbreak) with multilanguage support as I tried.
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
headline
SourceMod Moderator
Join Date: Mar 2015
Old 06-21-2017 , 14:28   Re: Translator Plugin
Reply With Quote #5

Quote:
Originally Posted by Mitchell View Post
Could you use Client's settings to figure out if their game is in a different language, then the plugin will attempt to translate what ever message to their language?
That's a great idea and would be cool to make this plugin seemless

Quote:
Originally Posted by Franc1sco View Post
Yes, that is the intention. I would like to see a lot of servers (specially jailbreak) with multilanguage support as I tried.
Cool because it's a very simple backend, but I don't want this to be specific just to Jailbreak.

Just requires this dependency.

I plan on changing a few things when it comes to this simple script and I may change the dependency to something a little better at some point. I'm down to work with you on this, Francisco. Feel free to msg me on steam.

PHP Code:
<?php
require_once ('vendor/autoload.php');
use \
Statickidz\GoogleTranslate;

$text $_GET['input'];
$target $_GET['target'];

$trans = new GoogleTranslate();
$result $trans->translate(''$target$text);

echo 
htmlspecialchars($result);

?>

Last edited by headline; 06-21-2017 at 14:54.
headline is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 06-21-2017 , 17:19   Re: Translator Plugin
Reply With Quote #6

Quote:
Originally Posted by Headline View Post
Just requires this dependency.
Isn't just better to make the curl request from the plugin than using that library and a webserver?

Last edited by Addicted.; 06-21-2017 at 17:20.
Addicted. is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 06-20-2017 , 13:07   Re: Translator Plugin
Reply With Quote #7

Could you use Client's settings to figure out if their game is in a different language, then the plugin will attempt to translate what ever message to their language?
Mitchell is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 06-22-2017 , 00:32   Re: Translator Plugin
Reply With Quote #8

I mean you're not wrong with the fact that it's a workaround, but it's a workaround that is free and usable. The good thing about it being a web interface is that if it were to break we could always switch the php backend without the plugin failing.
headline is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 06-22-2017 , 09:06   Re: Translator Plugin
Reply With Quote #9

Quote:
Originally Posted by Headline View Post
I mean you're not wrong with the fact that it's a workaround, but it's a workaround that is free and usable. The good thing about it being a web interface is that if it were to break we could always switch the php backend without the plugin failing.
Yeah, the only reason I say that is because many people don't have their own webserver for a plugin like this.
Addicted. is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 06-22-2017 , 10:34   Re: Translator Plugin
Reply With Quote #10

Quote:
Originally Posted by Addicted. View Post
Yeah, the only reason I say that is because many people don't have their own webserver for a plugin like this.
True! Mine will always be up for them tho
headline is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 09:35.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode