Tounges.js

A good translation API is tricky to find. Most are expensive, hard to use, and/or limit hourly usage. Tounges.js is completely different. It's free, easy to install, and simple to use. No API key or account is required.

Setup

You will have to upload this file into your website/project: tounges.html
It's important for this file to be in the same directory/folder as the page that uses it and for the file to keep the name "tounges.html."

After that, you can simply use the following tag in the HTML document in which the API will be used:

Usage

Once the API is set up, you can use the function translate(targetLanguage, text, sourceLanguage) to translate a string. The parameter targetLanguage must be a string equal to the ISO-639-1 code for one of the languages available on Google Translate (see the table below). text can be any word, phrase, sentence, or even group of paragraphs in any of the languages available on Google Translate. It can be any primitive data type (strings, booleans, numbers, or undefined). Finally, the sourceLanguage is an optional parameter that can either be equal to the ISO-639-1 code for one of the languages available on Google Translate or "auto", its default value.

Languages Available on Google Translate

Language ISO-639-1 code
Afrikaans af
Albanian sq
Amharic am
Arabic ar
Armenian hy
Azerbaijani az
Basque eu
Belarusian be
Bengali bn
Bosnian bs
Bulgarian bg
Catalan ca
Cebuano ceb
Chinese (Simplified) zh-CN
Chinese (Traditional) zh-TW
Corsican co
Croatian hr
Czech cs
Danish da
Dutch nl
English en
Esperanto eo
Estonian et
Finnish fi
French fr
Frisian fy
Galician gl
Georgian ka
German de
Greek el
Gujarati gu
Haitian Creole ht
Hausa ha
Hawaiian haw
Hebrew iw
Hindi hi
Hmong hmn
Hungarian hu
Icelandic is
Igbo ig
Indonesian id
Irish ga
Italian it
Japanese ja
Javanese jv
Kannada kn
Kazakh kk
Khmer km
Kinyarwanda rw
Korean ko
Kurdish ku
Kyrgyz ky
Lao lo
Latin la
Latvian lv
Lithuanian lt
Luxembourgish lb
Macedonian mk
Malagasy mg
Malay ms
Malayalam ml
Maltese mt
Maori mi
Marathi mr
Mongolian mn
Myanmar (Burmese) my
Nepali ne
Norwegian no
Nyanja (Chichewa) ny
Odia (Oriya) or
Pashto ps
Persian fa
Polish pl
Portuguese (Portugal, Brazil) pt
Punjabi pa
Romanian ro
Russian ru
Samoan sm
Scots Gaelic gd
Serbian sr
Sesotho st
Shona sn
Sindhi sd
Sinhala (Sinhalese) si
Slovak sk
Slovenian sl
Somali so
Spanish es
Sundanese su
Swahili sw
Swedish sv
Tagalog (Filipino) tl
Tajik tg
Tamil ta
Tatar tt
Telugu te
Thai th
Turkish tr
Turkmen tk
Ukrainian uk
Urdu ur
Uyghur ug
Uzbek uz
Vietnamese vi
Welsh cy
Xhosa xh
Yiddish yi
Yoruba yo
Zulu zu

The function will return a promise, so to actually use the data you must use the .then() method. For example, the following will log an object containing the translation data of "Hello world" in Spanish to the console:

translate("es", "Hello world").then(data => {
  console.log(data);
});
The object returned contains several properties that describe the translated text.

Data Properties

Property Name What it Means Data Type
oldText The original text before translation. String
newText The outputed text after translation. String
newLanguage The ISO-639-1 code of the language of the outputed text after translation. String

Demo

Translate any English sentence into Spanish using Tounges.js.