• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Google Translate API/something similar

Status
Not open for further replies.
Level 25
Joined
Feb 2, 2006
Messages
1,690
Hi,
I'd like to write a tool which does automatically translate texts from German into English and replaces them in a new output file or directly in the text.


Unfortunately, I have no experience with an API like this. Google translate seems to use the input text as GET parameter. Beside I've found this: Translating Text | Google Cloud Translation API Documentation | Google Cloud Platform
but apparently you need an application key and therefore to pay for it?

What would be the best way to realize this using simple HTTP requests? Just make a call like:
Google Translate

and parse the result? Or is there any better API?

edit:
Found this service: Google Translator Toolkit
But I am not sure if it can parse war3map.wts files and if there is a HTTP API.

I'd like to write a tool which parses the war3map.wts file and makes a request for every entry of the war3map.wts file.
 
Last edited:
Level 3
Joined
May 19, 2010
Messages
35
You can use the API that chrome uses to translate websites. Just access the URL "https://translate.googleapis.com/translate_a/single?client=gtx&sl={fromCulture}&tl={toCulture}&dt=t&q={text}" (replace the stuff in { } by your text). The response is something like JSON that can be easily parsed. I wrote a plugin for a japanese game that translates all text using google, you can look at the code here (Game is NSFW, github link is not :wink:)
 
Level 3
Joined
May 19, 2010
Messages
35
Well that's really nice, now one only has to learn network programming (socksets, protocols, encryption, etc.) and apply this knowledge into a program... ;P
You don't have to invent the weel again, there are many great resources and libs to do that. I don't know what programming language you want to use, but here are some ways:
Python: What is the quickest way to HTTP GET in Python?
C++: GitHub - whoshuu/cpr: C++ Requests: Curl for People, a spiritual port of Python Requests
Java: How to send HTTP request GET/POST in Java - Java2Blog
 
Status
Not open for further replies.
Top