Stay organized with collections
Save and categorize content based on your preferences.
The Cloud Translation API is available to anyone wishing to integrate with the
Cloud Translation API 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 how the
resulting text must be displayed on your site. This document and
Attribution Requirements are intended to
help you meet these requirements.
If unaltered Cloud Translation API results are published and made searchable on the
web, you are required to designate the translated text as machine translated
content. For example, Google has quality guidelines about automatically
generated
content
and guidance about how to prevent it from showing up in search
results.
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
Cloud Translation 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:
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:
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:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Translation API Markup\n\nThe Cloud Translation API is available to anyone wishing to integrate with the\nCloud Translation API from their own site or application. Use of these APIs is\ngoverned by the [Terms of Service](/terms). Among other\nthings, these Terms require that you adhere to certain guidelines on how the\nresulting text must be displayed on your site. This document and\n[Attribution Requirements](/translate/attribution) are intended to\nhelp you meet these requirements.\n\nIf unaltered Cloud Translation API results are published and made searchable on the\nweb, you are required to designate the translated text as machine translated\ncontent. For example, Google has quality guidelines about [automatically\ngenerated\ncontent](https://developers.google.com/search/docs/advanced/guidelines/auto-gen-content)\nand guidance about how to [prevent it from showing up in search\nresults](https://developers.google.com/search/docs/advanced/crawling/control-what-you-share).\n\nFor short snippets or sections within a HTML document\n-----------------------------------------------------\n\nWrap the translated text in a `\u003cdiv lang=\"...\"\u003e\u003c/div\u003e`\n(for blocks) or `\u003cspan lang=\"...\"\u003e\u003c/span\u003e` (for inline\nfragments) and set the `lang=\"\"` attribute to the appropriate\nlanguage code formed as follows:\n\n- Use the following format to set `lang=\"\"`: \\\u003clanguage code of the language to which the text was translated\\\u003e-x-mtfrom-\\\u003clanguage code of original language\\\u003e\n- For example, for French text that was machine translated from the original English text, the HTML tag should be: `\u003cspan lang=\"fr-x-mtfrom-en\"\u003eBonjour\u003c/span\u003e` or `\u003cdiv lang=\"fr-x-mtfrom-en\"\u003e Bonjour \u003c/div\u003e`\n- If the source language or target language is unknown, use the \"und\" language\n specification to indicate undetermined language. For example,\n `\u003cspan lang=\"und-x-mtfrom-und\"\u003e ... \u003c/span\u003e` indicates\n undetermined source or target languages.\n\n- Alternatively, put a `lang=\"\"` attribute around whatever element\n already wraps the translated text. For example, if the unaltered\n Cloud Translation API results are in a `\u003cp\u003e` paragraph, then put\n the `lang=\"\"` on the `\u003c/p\u003e` as in\n `\u003cp lang=\"ar-x-mtfrom-jp\"\u003e` for text translated from\n Japanese to Arabic).\n\nFor entire documents or web page\n--------------------------------\n\nFor an entire page, when the original document is not available online or the\nURL of the original document is not yet known, put the lang=\"\" attribute as\ndescribed in the previous section on the \\\u003chtml\\\u003e element: \n\n \u003cDOCTYPE HTML\u003e\n \u003chtml lang=\"en-x-mtfrom-fr\"\u003e\n \u003chead\u003e\n \u003ctitle\u003eThe Bee\u003c/title\u003e\n ...\n\nFor the entire page, when the original document is available online, put a\n\\\u003clink\\\u003e element in the \\\u003chead\\\u003e of the HTML document, with the rel=\"\"\nattribute set to \"alternate machine-translated-from\", the hreflang=\"\" attribute\nset to the original language code, and href=\"\" is set to the original page, as\nin: \n\n \u003cDOCTYPE HTML\u003e\n \u003chtml lang=\"en-x-mtfrom-fr\"\u003e\n \u003chead\u003e\n \u003ctitle\u003eThe Bee\u003c/title\u003e\n \u003clink rel=\"alternate machine-translated-from\" hreflang=\"fr\"\n href=\"http://fr.example.com/abeille.html\"\u003e\n \u003c/head\u003e\n \u003cbody\u003e\n ...\n\nThe HTML code above specifies that this page is machine translated from French\nto English and the original French document is located at the fictitious\n`http://fr.example.com/abeille.html`.\n\nFor more information, language codes are described below:\n\n- [IANA language subtag registry](http://www.iana.org/assignments/language-subtag-registry)\n- [IETF language tag](http://en.wikipedia.org/wiki/IETF_language_tag)"]]