This document does not cover features that are still under development, such as features in the beta, dev and canary channel and active field trials, or Android apps on ChromeOS if Play Apps are enabled. Here we’re focusing on the desktop version of Chrome we touch only tangentially on ChromeOS and Chrome for Mobile. This document also describes the controls available to you regarding how your data is used by Chrome. This document describes the features in Chrome that communicate with Google, as well as with third-party services (for example, if you've changed your default search engine). Translate a query into multiple languages simultaneously.Last modified: Febru(Current as of Chrome. api/translate > /api/languages > /api/tts /api/translate This proxy API does all that for you! APIs Moreover, there are at least 4 different result formats (depending on the target language, complexity of the query, etc.) so you must learn to adapt. The API result is made of arrays of arrays (like a JSON that was stripped out of its labels), so you are left to figure out what every field means. parse the result to get the data you wished for (which is not as straight forward as you'd might expect).call the AJAX API with (query, tk, targetLang, sourceLang.calc: tk := googleHashFunction(query, tkk).get your hands on some private key (by loading Google Translate website) => tkk.This private key changes every hour (but it seems that old keys can be used for quite a long time before they actually expire).įor more info on the hash function, see tk-hash.js.Īs a conclusion, in order to use Google's API directly, you would have to: It turns out that " tk" is a hash value based on your query (the string you wish to translate) and some private key (called TKK), which is embedded in your DOM when you load the Google translate page. Try to fake it with random values, and you will get HTTP status 403 (Forbidden). You would notice that the API requires around a dozen parameters, most of which you will quickly understand or walk around them easily. Well, sure, just open the networking panel of the Dev tools and see where the requests go. ¡¿ Why do I need a proxy ?!Ĭan't I just call the API used by Google Translate? It currently only supports the queries "dog" and "cat", in French, Spanish, German and Hebrew, but you may modify the data file for more :). In this mode, no requests will be sent to Google, but it uses the same "production" code to extract the TKK and send queries (useful for IT tests). You may also work in test mode, where translation system is mocked by the data contained in data.json file. You may also disable Postgres: "sed -i -e 's/ENABLE_PSQL=true/ENABLE_PSQL=false/'. env with the correct local credentials: username/password/port (defaults are postgres/1234/5432) => make sure PostgreSQL is running in the background. => Install Postgres => create a local database: "psql -c 'create database google_translate_server ' -U postgres" => configure.
0 Comments
Leave a Reply. |