SA-MP Forums Archive
HTTP() & ****** Translator - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: HTTP() & ****** Translator (/showthread.php?tid=605322)



HTTP() & ****** Translator - Luis- - 17.04.2016

Hey!

Is it possible to actually use the HTTP() function to send a request to the ****** Translator website in order to return the translated text in game?


Re: HTTP() & ****** Translator - Crystallize - 17.04.2016

Yes it is there are even script made for this , search.


Re: HTTP() & ****** Translator - Luis- - 17.04.2016

I have searched. I'm not looking to download a script to use, I want to make one myself. The ones I have found are "text to speech" which I don't actually want. I'd rather have it actually translate the text I send and return the translated text.


Re: HTTP() & ****** Translator - jlalt - 17.04.2016

****** translator if I'm not wrong blocking directly http texts so samp http function can't read the text it's translating, here's a website that would work on samp http( thingy

PHP код:
 udcs-tss.com/******/?msg=%s&langin=%s&langout=%
example:
PHP код:
 udcs-tss.com/******/?msg=Hi&langin=en&langout=es 
lang-in even if wrong it detecting the real one of it auto


Re: HTTP() & ****** Translator - Stuntff - 17.04.2016

Quote:
Originally Posted by jlalt
Посмотреть сообщение
****** translator if I'm not wrong blocking directly http texts so samp http function can't read the text it's translating, here's a website that would work on samp http( thingy

PHP код:
 udcs-tss.com/******/?msg=%s&langin=%s&langout=%
example:
PHP код:
 udcs-tss.com/******/?msg=Hi&langin=en&langout=es 
lang-in even if wrong it detecting the real one of it auto
or
Код:
stock Trans(id,str[]) 
{ 
     new stream[114]; 
    format(stream,sizeof(stream),"http://translate.******.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=%s&tl=En-gb",str); 
    PlayAudioStreamForPlayer(id,stream); 
    return 1; 
}



Re: HTTP() & ****** Translator - Crayder - 17.04.2016

@Luis- You just have to look for the official API. ****** has one for just about ALL of their services. All you need to do is sign up (it's free, no credit or anything) and get your personal key.


Re: HTTP() & ****** Translator - J0sh... - 17.04.2016

Crayder:
****** Translate API is a paid service. For website translations, we encourage you to use the ****** Website Translator gadget.




Re: HTTP() & ****** Translator - Luis- - 18.04.2016

Hmm. So, i'm guessing there's no way to actually return the translated text in text form instead of audio form?


Re: HTTP() & ****** Translator - Karan007 - 18.04.2016

There is a way. I saw it in a server.


Re: HTTP() & ****** Translator - Stinged - 28.04.2016

I'm sorry for the late reply.
What jlalt said was very helpful.

This is only a testing code, so you'll have to change the HTTP index if you want multiple people to use this.

Also, the "langout=fr" at the end of the URL is the language the website will translate the string to.
I've only tried it with french, but I think it'll cause problems once it starts to show the none english characters. (For example й and shit like that)

Signs like # will fuck it up so I think you should limit the input text to A-Z only.
You can always find a fix for that, but I'm not that good with URLs, and I'm a bit lazy.
Код:
forward HTTP_TranslateResponse(index, response_code, data[])

public OnGameModeInit()
{
	new str[128];
	strcat(str, "Hello, my name is James. How are you?");
	for (new i; i < 82; i++)
	{
	    if (str[i] == ' ')
	    {
	        str[i] = '+';
	    }
	}
	format(str, sizeof (str), "udcs-tss.com/******/?msg=%s&langin=en&langout=fr", str);
	HTTP(0, HTTP_GET, str, "", "HTTP_TranslateResponse");
	return 1;
}

public HTTP_TranslateResponse(index, response_code, data[])
{
    if(response_code == 200)
    {
        if (strfind(data, "\n") != -1)
        {
            strdel(data, 0, strfind(data, "\n")+1);
            strdel(data, strlen(data)-6, strlen(data));
        }
        print(data);
    }
    else
    {
        printf("Error ID: %i", response_code);
    }
}