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

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
Mitchell
~lick~
Join Date: Mar 2010
Old 06-20-2017 , 13:07   Re: Translator Plugin
Reply With Quote #4

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
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 06-20-2017 , 13:26   Re: Translator Plugin
Reply With Quote #5

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 #6

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 #7

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-21-2017 , 18:31   Re: Translator Plugin
Reply With Quote #8

Quote:
Originally Posted by Addicted. View Post
Isn't just better to make the curl request from the plugin than using that library and a webserver?
it depends on how long the JSON payload is.
Mitchell is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 06-21-2017 , 18:44   Re: Translator Plugin
Reply With Quote #9

Quote:
Originally Posted by Addicted. View Post
Isn't just better to make the curl request from the plugin than using that library and a webserver?
Curl request to.... what exactly?
headline is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 06-21-2017 , 22:19   Re: Translator Plugin
Reply With Quote #10

Quote:
Originally Posted by Headline View Post
Basically, I want gameservers to be engaging for all players across all language barriers. This is how I think this can be accomplished.
I like the idea of "multi-national", and have always tried to prefer my projects/communities/services/etc that way -

However, seeing as online translators don't always do things very good, ... it might still be a problem to get something that's simply understandable out of some words.

Quote:
Originally Posted by Addicted. View Post
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?
Quote:
Originally Posted by Headline View Post
Curl request to.... what exactly?
Directly to Google Translation API, the official way, would be a start?

The "library" you use is doing is a hacky workaround that might stop working one day.

However, Google Translation API (click for details!) probably doesn't make a such plugin very attractive after all.

- I'm not trying to be a show-stopper, and I'm perfectly fine with the idea though. But hacky workarounds are quite often the mother of all fuck ups!


All that being said, in regards to the language detection / choices:

It could be done based on cl_language, which has the user's Steam language settings.

A language selection menu could similar to GeoIP Language Selection
plugin be presented at the first join (when language is known). Instead of listing all languages, it could be a limited selection languages based on information of "Main foreign languages" of countries like this:

-> https://en.wikipedia.org/wiki/Languages_of_Denmark
-> https://en.wikipedia.org/wiki/Languages_of_Sweden
-> https://en.wikipedia.org/wiki/Languages_of_Norway
-> https://en.wikipedia.org/wiki/Languages_of_Germany
-> https://en.wikipedia.org/wiki/Languages_of_Switzerland

Options for users connecting depending on GeoIP country would be:

Code:
DK/Denmark		DNT, Danish, English, German, Swedish
SE/Sweden		DNT, Swedish, English, German, French, Norwegian, Danish
NO/Norway		DNT, Norwegian, English, French, German, Swedish, Finnish, Russian
DE/Germany		DNT, German, English, French, Russian
CH/Switzerland		DNT, German, French, Italian, English
DNT obviously stands for Do Not Translate.

A side note, it would also be worth to have a list of languages that the user knows/understand.

I might be able to read Danish, Swedish and Norwegian, but not German, and would therefore be awesome to have German translated, where I would like Danish, Swedish and Norwegian as they were.

But with that one, there would be the issue with proper language detection though. Sometimes, Google Translate doesn't even do that good enough.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].

Last edited by DarkDeviL; 06-21-2017 at 22:20.
DarkDeviL is offline
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

Forum Jump


All times are GMT -4. The time now is 00:49.


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