Question
Which is thetranslate
attribute for and how should I use it?
Fast answer
Thattranslate
Attributeand HTML5indicates that the content of the element should or should not be translated. There is no effect on the rendered page (although you can of course format it if you can find a good reason to). For example,
<h1>Using HTML<span class="kw" translate="no">translate</span>Attribute</h1>
The attribute can appear on any element and only needs two values:y
ono
. if the value isno
, translation tools must protect the text of the element from translation. The translation tool in question could be an automatic translation engine like those used in the online services of Google, Microsoft, and Yandex. Or it could be a human translator's "workbench" tool that prevents the translator from accidentally changing the text.
Setting this translation flag on an element applies the value to all content in the contained element. HTML5 has a list of attributes that should be translated by default, but these attributes should not be translated if they are on an element wheretranslate
is set tono
. Otherwise, the attributes should not be translated.
If a page does nottranslate
attribute, a translation system or translator should assume that all text should be translated. Thaty
So the value is unlikely to find much use, although it could be very useful when you override a translation flag in a parent and need to specify some bits of text to translate. For example, you might want to translate the natural language text in source code examples, but not leave the code translated.
details
Because it is necessary?
Adding thetranslate
Attributing to your page can help readers better understand your content when running it through machine translation systems, and can save high-performing multi-language translation providers a significant amount of cost and effort.
You find yourself needing to do it quite often. There is an example in the HTML5 spec about the bee game. Here is a similar but real example where the documentation to be translated was related to a machine with untranslated English text in the hardware control panel.
<p>Click the progress bar or Continue button
<span class="panelmsg" translate="no">CONTINUAR</span> button
on the printer's control panel.</p>
in oneGermanThe translation becomes:
<p>Press Continue on the status screen or on the
Try <span class="panelmsg" translate="no">CONTINUE</span>
on your printer.</p>
Here are some more real life examples of content that could benefittranslate
Attribute. The first comes from a book and cites the title of a work that must remain in the original language.
<p>The question in the title <cite translate="no">How far can it go?</cite> refers to both the subversion of traditional religious beliefs through radical theology and the subversion of conventions literary through "breaking". Frame"...</p>
The following example is directly from an English site about French bread, which is French for bread.pain– and the code does not containtranslate
Attribute. The original is in English, which means that a machine translation translates the English wordpainlike a very uncomfortable bodily sensation, rather than something you eat.
<p>Welcome to <strong>French pain</strong> on Facebook. Sign up now to write reviews and connect with <strong>French Pain</strong>. Help your friends discover great places by recommending <strong>French pain</strong>.</p>
best plugintranslate = "not"
For himhard
Items. (And by the way, it would also be useful for things like voice browsers to include the word toopaincon<span lang="fr">...</span>
.)
You can also use it to protect keywords, code samples, or translation samples. In the first paragraph of the following example, markup that looks like common English words is translation protected. The source code for the second paragraph ensures that the entire paragraph remains in English.
<p>This is an example of the <span class="kw" translate="no">label<span> element using the <span class="kw" translate="no">for</span> attribute: < / p>
<code translate="no"><label for="postcode">Enter your postcode to find the nearest store:</label> <input id="postcode" type="text"></code>
When should translate="yes" be used?
Thaty
Value oftranslate
The attribute is mainly used to override the effect of the setting.translate
ano
. For example, we may want to allow the natural language text of the above source code to be translated while protecting the code itself (i.e., keywords likeHang tags
,Pro
,Postal Code
,Prohibited
, Etc.). We could do this by surrounding the natural language text with elements that have thattranslate
Attribute.
<p>This is an example of the <span class="kw" translate="no">label<span> element using the <span class="kw" translate="no">for</span> attribute: < / p>
<code translate="no"><label for="postcode"><span translate="yes">Enter your postal code to find the nearest store</span>:</label> <input id=" postcode" type="text"></code>
work with attributes
Handling attribute values during translation can be problematic. In general, attribute values are part of the page syntax and therefore should not be translated. If this is the case, the page is broken. In some cases, however, the values contain human-readable text (eg.title
,alternative
, yposition marker
attribute values in HTML), although this is not recommended.*
For example, you can't use flags on attribute values to handle bidirectional text in languages like Arabic and Hebrew, or to flag things like language changes. And, of course, it can be difficult to determine which attribute values should be translated and which shouldn't. It is also difficult to identify part of an attribute value that should be left untranslated, or an attribute value that should be left untranslated even though the element's content is translated.
The HTML specificationattribute listswhich should be treated as translatable. Attribute values that are not included in this list should not be translated.
When a 'translatable' attribute value appears on an element that hastranslate
to placeno
, then hopefully the value of the attribute will also remain untranslated.
Of course this can cause problems in cases where you are fightingagainyou want the attribute values to be translated but not the element content or vice versa. In some cases, these situations can be mitigated by nesting the markup in question. For example, you could have an outerTeams
article withtranslate
to placey
who takes themtitle
Attribute to translate. In thisTeams
could you put anotherTeams
contranslate
to placeno
y contains the content of the element. Here's how articles like the one you're reading now handle links to translated versions of a page: thetitle
The attribute of the outer element bears the name of the designated language, and the inner element bears the name of that language in the language itself (which should not be changed). This also helps to tag the language with thelanguage
Attribute.
The following example shows how the word "English" can be escaped when it is a link to the English version of the document when translating a German page into another language. the informativetitle
attribute would be translated. Without the Translate mark, online services are now more likely to translate the word "English" into the target language equivalent or "German".
<span title="English"><a href="article.en.html" translate="no" lang="en">English</a></span>
However, since these are attribute values, it is not yet possible to determine ifTo youof the text in the attribute value must be protected from translation.
(Note that the HTML5 specification is not stable at the time of writing and implementations may not yet follow the specification.)
This approach differs from the general approach recommended by the ITS specification for XML-based languages. ITS (see below) recommends leaving attribute values untranslated by default, but also provides a way to specify specific attributes that should be translated regardless of their context.
Add translation flags to a page
Thattranslate
Of course, the attribute can be added to a page by a content author who pays attention to how the page should look after translation. This is particularly useful for protecting content when a reader takes a page through an automatic translation service, such as those offered by Google, Microsoft, and Yandex.
In industrial translation scenarios, localizers can add attributes during the translation preparation phase to avoid the multiplier effects of dealing with translation errors in a large number of languages. This can be done through automated processes such as B. Entity recognition tools that automatically recognize proper names.
It is also possible to use external files to reference (among other things) marks that should not be translated. For example, you might want to specify that allTeams
Elements with a specific class name should not be translated. One way to do this is described by theInternationalisierungs (ITS) Label SetSpecification. A set of such rules can be applied to one page or many pages at the same time. Content developers and localizers can work closely together to establish these rules for a faster and better localization process.
Implementation support for the translation flag
The codetranslate = "not"
is supported by online translation services from Google, Microsoft, and Yandex at the time of writing. The use oftranslate = "me"
Microsoft does not support translation within a part of the document where translation is not allowed, but the other two services do.
See the results of the latest tests.
The MultilingualWeb-LT working group that worked on theinternationalization tag setspecification, has compiled a document,Metadata for the multilingual web: usage scenarios and implementations, which describes other applications and usage scenarios in which the translation flag is recognized.
Legacy Approaches of Online Translation Services
Beforetranslate
attribute was defined, Google and Microsoft online translation services support a number of other non-standard ways of expressing similar ideas.
Google and Microsoft supportclass = "air"
, but replacing aClass
Attribute value with an attribute that is a formal part of the language makes this function much more reliable, especially in larger contexts. For example, a translation preparation tool could be based on the meaning of HTML5translate
The attribute is always what is expected. Also, it will be easier to translate the concept to other scenarios, such as B. other translation APIs or localization standards, such asXLIFF.
Microsoft apparently supportsstyle="air"
. This isn't one of the options that Google lists for their online service, but then again, they do have things that aren't available through Microsoft's service.
For example, if you have an entire page that you don't want to translate, you can add<meta name="google" value="air">
withinKopf
element of your page and Google is not translating any content on that page. (But they also support<meta name="google" content="air">
.) This shouldn't be specific to Google, and only one way to do it, ie.translate = "not"
about himhtml
day, it is much cleaner.
Microsoft and Google translation engines don't translate any content on it either.Code
Items. Note, however, that you don't seem to have a choice in the matter; there doesn't seem to be any instructions on how to override this if you want.Code
Content of the translated item.
As mentioned, the new HTML5translate
The attribute provides a simple, standard HTML function that can replace and simplify all of these different approaches and help authors develop content that also works with other systems.
keep reading
-
similar links,HTML and CSS creation
- Specification of what is going to be translated and what is not.
FAQs
How do you translate attributes in HTML? ›
The translate attribute specifies whether the content of an element should be translated or not. Test: Use the Google translate box (at the top of the page) to change to another language, and look what happens to the word "ice cream" below: Here we use translate="no": ice cream.
How to translate text in HTML? ›...
To translate attributes inside an HTML element:
- Add the placeholder to the translation area, then click on it.
- A modal will appear. ...
- When you're done translating the attributes, click the Apply button. ...
- After you're finished translating the string, hit Save.
- Open an app with text you can copy.
- Highlight the text you want to translate. Copy.
- On your current screen, tap Google Translate .
- Choose the language you want.
Follow the steps to add a google translate button on your website: Step 1: Start with a basic web page and add a “div” element. In the code below a “div” element with the id “google_translate_element” is created. Step 2: Add google translate api reference.
What are HTML attributes examples? ›- <element> is the HTML element.
- name1 and name2 are the attribute names.
- value1 and value2 are the attribute values.
- Attribute values are set between single quotes (') or double quotes (").
- Examples include id, style, class, name, href, etc.
- Audio Element.
- Canvas Element.
- contenteditable Attribute.
- Input Types.
- Keygen Element.
- Meter Element.
- Output Element.
- Progress Element.
- In your browser, go to Google Translate.
- At the top, click Documents.
- Choose the languages to translate to and from. ...
- Click Browse your computer.
- Select the file you want to translate.
- Click Translate and wait for the document to finish translating.
The translate() method returns a string where some specified characters are replaced with the character described in a dictionary, or in a mapping table. Use the maketrans() method to create a mapping table. If a character is not specified in the dictionary/table, the character will not be replaced.
How can I translate words directly? ›- In your document, highlight the text you want to translate.
- Select Review > Translate > Translate Selection.
- Select your language to see the translation.
- Select Insert. The translated text will replace the text you highlighted in step 1.
- On your Android phone or tablet, open the Chrome app .
- To the right of the address bar, tap More. ...
- Tap Languages. ...
- Tap Automatically translate these languages.
- To add a language, tap Add language and select the language to always translate.
How to translate image text? ›
- On your Android phone or tablet, open the Translate app .
- Choose the languages you want to translate to and from. From: Choose a language or tap Detect language . ...
- On the app home screen, tap Camera . To translate text from an image you've already captured: tap All Images .
Press Ctrl+M (⌘M on Mac) to translate the whole page or selection.
How do I get a website to automatically translate? ›- choose “Translate this page to” a preferred language from the context menu. ...
- use the shortcuts keys Alt+P (default)
- set Webpage Translation on the.
In a nutshell
Always add a lang attribute to the html tag to set the default language of your page. If this is XHTML 1. x or an HTML5 polyglot document served as XML, you should also use the xml:lang attribute (with the same value). If your page is only served as XML, just use the xml:lang attribute.
- Create the Static HTML. We start with the bare-bones HTML page. ...
- Add Dropdown Click Handler. ...
- Add JQuery AJAX Call To Invoke Google Translate API. ...
- Add The Form Placeholder Update Code. ...
- Add Login for “click” Event Handler.
- Single valued Attribute. Attributes having a single value for a particular item is called a single valued attribute. ...
- Multi-valued Attribute. Attribute having a set of values for a single entity is called a multi-valued attribute. ...
- Derived Attributes or stored Attributes. ...
- Complex Attribute.
There are six such types of attributes: Simple, Composite, Single-valued, Multi-valued, and Derived attribute. One more attribute is their, i.e. Complex Attribute, this is the rarely used attribute.
What is attribute name in HTML? ›The name attribute specifies a name for an HTML element. This name attribute can be used to reference the element in a JavaScript. For a <form> element, the name attribute is used as a reference when the data is submitted. For an <iframe> element, the name attribute can be used to target a form submission.
What are the 3 types of attribute in HTML? ›- The value Attribute. The input value attribute specifies an initial value for an input field: ...
- The readonly Attribute. ...
- The disabled Attribute. ...
- The size Attribute. ...
- The maxlength Attribute. ...
- The min and max Attributes. ...
- The autofocus Attribute. ...
- The height and width Attributes.
A few of the basic tags that can be seen in almost all the HTML documents are <HTML>, <! Doctype html>, <head>, <span>, <body>, <p>, <div>, <u>, <sub>, <sup>, <strong>, <em>, <hr>, <br>, <li>, <ol>, <ul>, <a href =…>, header tags like h1, h2, h3, .., <img src=””/>, etc.
What are the 10 basic HTML tags? ›
- <html> … </html> — The root element. ...
- <head> … </head> — The document head. ...
- <title> … </title> — The page title. ...
- <body> … </body> — The page's content. ...
- <h1> … </h1> — A section heading. ...
- <p> … </p> — A paragraph. ...
- <a> … </a> — A link. ...
- <img> — An image.
...
Translate text
- On your Android phone or tablet, open the Translate app .
- Choose a language to translate to and from. ...
- Enter the word or phrase you want to translate.
The translate global attribute is an enumerated attribute that is used to specify whether an element's translatable attribute values and its Text node children should be translated when the page is localized, or whether to leave them unchanged.
What does translate do in CSS? ›The translate() CSS function repositions an element in the horizontal and/or vertical directions. Its result is a <transform-function> data type.
What is the formula for translating? ›What is the formula for translation? The formula for translation or vertical translation equation is g(x) = f(x+k) + C.
What are the three ways of translation? ›In the modern world, there are three types of translation: human translation, machine translation, and post-edited translation. These three examples of translation are all viable ways of rendering content into another language.
What is the best way to translate the content on? ›Google Translate
Select the source language and target language and upload your document. Click on “Translate.” Google will give you back a translated document.
Automatic translation uses technology, not just human translators, to quickly translate text into different languages for multilingual websites. It also refers to the movement of processes within the translation workflow, including collecting translatable content, localization, reviewing, and publishing.
How do I translate a Web page into English? ›- Launch Google Chrome and go to the Google Translate website i.e. translate.google.com.
- Type the entire URL of your website in the text box on the left.
- Select the new language you wish to translate your website into.
- Click the Translate button.
- Google Translate. Google Translate needs no introduction, being probably the most well-known machine translation software out there. ...
- DeepL Translator. ...
- Bing Microsoft Translator. ...
- SYSTRAN Translate. ...
- Amazon Translate.
Is there an instant language translator? ›
Langogo Genesis 2in1 AI Translator Device
This portable AI translator is one of the best and most efficient AI translators. This tool has one button, and it automatically detects and translates 104 languages. It can translate four of the languages offline.
To do so, first, launch the Google Translate app on your phone. In the app, tap “Camera.” On the camera view page, from the top, select both source and target languages for your picture translation. To make the app detect the source language, choose “Detect Language” in the source language field.
How to extract text from an image? ›The process is similar in the mobile apps for Android and iOS. Open up an image with text in it, and you'll see an option to copy the onscreen text. The extracted text can be copied to the clipboard, used as a web search, or even translated with another tap.
How does image translation work? ›This is done by applying optical character recognition (OCR) technology to an image to extract any text contained in the image, and then have this text translated into a language of their choice, and the applying digital image processing on the original image to get the translated image with a new language.
What is the command to translate a page? ›Translate webpages in Chrome
On your computer, open Chrome. Go to a webpage written in another language. On the right of the address bar, click Translate . Chrome will translate your current webpage.
- Open Google Chrome app on a mobile device.
- Navigate to a webpage.
- Click the 3 dots in the toolbar (next to URL bar).
- Scroll down and click on “Translate”.
- A Google Translate toolbar should appear at the bottom of the screen.
Highlight or right-click on a section of text and click on Translate icon next to it to translate it to your language. Or, to translate the entire page you're visiting, click the translate icon on the browser toolbar. Learn more about Google Translate at https://support.google.com/translate.
How do I translate a page without popping up? ›- Try Incognito and Update Chrome. Press Ctrl+Shift+N to open a new window in Incognito mode. ...
- Disable Pop-Ups in Chrome. The pop-up notification offering you to translate the page in Chrome browser can be displayed by the site itself. ...
- Disable Chrome's Native Translate Setting.
- Upload your videos. Upload your videos to Nova A.I. ...
- Subtitle your video. Pick the best way that suits your subtitling goals.
- Select your language. Select the language you want to translate to from the dropdown menu.
- Export your files.
Chrome and Safari use Google Translate to translate webpages. Firefox uses add-ons, including the Google Translator add-on.
What is a lang attribute in HTML? ›
The lang (or sometimes the xml:lang ) attribute specifies the natural language of the content of a web page. An attribute on the html tag sets the language for all the text on the page.
How to set lang attribute in HTML dynamically? ›- Yes it is...you can check it: $("html").attr("lang", language); alert($("html").attr("lang")): ...
- Pure js way: document.documentElement.setAttribute('lang','test');alert(document.documentElement.getAttribute('lang')); ...
- If you see the DOM structure (using 'view source'), 'lang' isn't getting injected.
- Define your expansion goals. The first step is to decide which languages you will add to your website. ...
- Choose your domain strategy. ...
- Choose the right software. ...
- Pick a plugin. ...
- Translate. ...
- Choose a place for the language selection menu. ...
- Design the language selection menu. ...
- Optimize.
There's no such thing as a “Javascript to HTML converter”. Javascript is a programming language, not a markup language. Browsers don't convert Javascript to HTML, they execute the Javascript code, and the effect of the Javascript code is to modify the HTML.
How to translate a text in CSS? ›The CSS translate() function is used to move elements in a two-dimensional space. It moves the position of the element on the plane by the amount provided by tx and ty . The translate() function accepts two arguments, indicating how much to move the element along the x and y axes respectively.
How do you edit attributes in HTML? ›To edit the content in HTML, we will use contenteditable attribute. The contenteditable is used to specify whether the element's content is editable by the user or not. This attribute has two values. true: If the value of the contenteditable attribute is set to true then the element is editable.
How do you modify attributes? ›Edit Attributes Attached to a Block Definition
In the list of attributes, double-click the attribute you want to edit, or select the attribute and click Edit.
- To get the value of an attribute, use the Node.attr(String key) method.
- For the text on an element (and its combined children), use Element.text()
- For HTML, use Element.html() , or Node.outerHtml() as appropriate.
- let attributeValue = element.getAttribute(attributeName); ...
- const link = document.querySelector('a'); let title = link.getAttribute('title'); ...
- <a href="/api" data-method="post">Save</a>
HTML attributes are generally classified as required attributes, optional attributes, standard attributes, and event attributes: Usually the required and optional attributes modify specific HTML elements. While the standard attributes can be applied to most HTML elements.
What are HTML attributes * Your answer? ›
An HTML attribute is a piece of markup language used to adjust the behavior or display of an HTML element. For example, attributes can be used to change the color, size, or functionality of HTML elements.
How do you check attributes in HTML? ›The checked attribute is a boolean attribute. When present, it specifies that an <input> element should be pre-selected (checked) when the page loads. The checked attribute can be used with <input type="checkbox"> and <input type="radio"> . The checked attribute can also be set after the page load, with a JavaScript.
Can HTML have custom attributes? ›The data-* attributes gives us the ability to embed custom data attributes on all HTML elements. The stored (custom) data can then be used in the page's JavaScript to create a more engaging user experience (without any Ajax calls or server-side database queries).
How do you create an attribute? ›- Click Edit > Attributes.
- Click New, or select the attribute to copy, and then click Copy.
- Type the name of the new attribute definition in the Attribute name field, and select the options that you want. For more information, click Help.
- Click OK to create the attribute definition.
At the Command prompt, changes attribute information in a block. You can filter the attributes to be changed based on attribute tag, current value, or object selection.
How do you select attributes? ›The [attribute|="value"] selector is used to select elements with the specified attribute, whose value can be exactly the specified value, or the specified value followed by a hyphen (-). Note: The value has to be a whole word, either alone, like class="top", or followed by a hyphen( - ), like class="top-text".
How do I extract text from an element? ›- let text = element. textContent;
- element. textContent = "I have changed!";
- let text = document. getElementById("myList"). textContent;
To get a data attribute through the dataset object, get the property by the part of the attribute name after data- (note that dashes are converted to camelCase). Each property is a string and can be read and written. In the above case setting article.dataset.columns = 5 would change that attribute to "5" .
What is attribute value in HTML? ›The value attribute specifies the value of an <input> element. The value attribute is used differently for different input types: For "button", "reset", and "submit" - it defines the text on the button. For "text", "password", and "hidden" - it defines the initial (default) value of the input field.
How do you fetch attribute value? ›The getAttribute() method is used to get the value of an attribute of the particular element. If the attribute exists, it returns the string representing the value of the corresponding attribute. If the corresponding attribute does not exist, it will return an empty string or null.