Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



Translate API Markup

The Google Translate API is available to anyone wishing to integrate with Google Translate from their own site or application. Use of these APIs is governed by the Terms of Service . Among other things, these Terms require that you adhere to certain guidelines on the resulting text must be displayed on your site. This document and Attribution Requirements are intended to help you meet these requirements.

If unaltered Google Translate API results are published and made searchable on the web, you are required to designate the translated text as machine translated content. This is required so Google and other search engines can distinguish between original and translated text.

In HTML, machine translated text should be enclosed as follows:

For short snippets or sections within a HTML document

Wrap the translated text in a <div lang="..."></div> (for blocks) or <span lang="..."></span> (for inline fragments) and set the lang="" attribute to the appropriate language code formed as follows:

  • Use the following format to set lang="" : <language code of the language to which the text was translated>-x-mtfrom-<language code of original language>
  • For example, for French text that was machine translated from the original English text, the HTML tag should be: <span lang="fr-x-mtfrom-en">Bonjour</span> or <div lang="fr-x-mtfrom-en"> Bonjour </div>
  • If the source language or target language is unknown, use the “und” language specification to indicate undetermined language. For example, <span lang="und-x-mtfrom-und"> … </span> indicates undetermined source or target languages.

Alternatively, put a lang="" attribute around whatever element already wraps the translated text. For example, if the unaltered Google Translate API results are in a <p> paragraph, then put the lang="" on the </p> as in <p lang="ar-x-mtfrom-jp"> for text translated from Japanese to Arabic).

For entire documents or web page

For an entire page, when the original document is not available online or the URL of the original document is not yet known, put the lang="" attribute as described in the previous section on the <html> element:

<DOCTYPE HTML>
  <html lang="en-x-mtfrom-fr">
    <head>
      <title>The Bee</title>
        ...

For the entire page, when the original document is available online, put a <link> element in the <head> of the HTML document, with the rel="" attribute set to "alternate machine-translated-from", the hreflang="" attribute set to the original language code, and href="" is set to the original page, as in:

<DOCTYPE HTML>
  <html lang="en-x-mtfrom-fr">
    <head>
      <title>The Bee</title>
      <link rel="alternate machine-translated-from" hreflang="fr"
            href="http://fr.example.com/abeille.html">
    </head>
    <body>
        ...

The HTML code above specifies that this page is machine translated from French to English and the original French document is located at the fictitious http://fr.example.com/abeille.html .

For more information, language codes are described below

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.