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

Translator Plugin


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 19:38.


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