AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   Translator Plugin (https://forums.alliedmods.net/showthread.php?t=298684)

headline 06-20-2017 10:49

Translator Plugin
 
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



Franc1sco 06-20-2017 12:01

Re: Translator Plugin
 
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.

headline 06-20-2017 12:24

Re: Translator Plugin
 
Quote:

Originally Posted by Franc1sco (Post 2530102)
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 :D

Mitchell 06-20-2017 13:07

Re: Translator Plugin
 
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?

Franc1sco 06-20-2017 13:26

Re: Translator Plugin
 
Quote:

Originally Posted by Headline (Post 2530108)
Im alright with releasing this php script, but under the agreement that if you make this plugin it will be released publicly :D

Yes, that is the intention. I would like to see a lot of servers (specially jailbreak) with multilanguage support as I tried.

headline 06-21-2017 14:28

Re: Translator Plugin
 
Quote:

Originally Posted by Mitchell (Post 2530116)
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 (Post 2530122)
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);

?>


Addicted. 06-21-2017 17:19

Re: Translator Plugin
 
Quote:

Originally Posted by Headline (Post 2530437)
Just requires this dependency.

Isn't just better to make the curl request from the plugin than using that library and a webserver?

Mitchell 06-21-2017 18:31

Re: Translator Plugin
 
Quote:

Originally Posted by Addicted. (Post 2530477)
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.

headline 06-21-2017 18:44

Re: Translator Plugin
 
Quote:

Originally Posted by Addicted. (Post 2530477)
Isn't just better to make the curl request from the plugin than using that library and a webserver?

Curl request to.... what exactly?

DarkDeviL 06-21-2017 22:19

Re: Translator Plugin
 
Quote:

Originally Posted by Headline (Post 2530078)
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. (Post 2530477)
Quote:

Originally Posted by Headline (Post 2530437)
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 (Post 2530502)
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.


All times are GMT -4. The time now is 03:08.

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