SwiftLingo

Excluding Content from Translation

This document explains how to use the standard translate="no" HTML attribute to prevent specific parts of your web page from being translated by SwiftLingo.

Purpose

While SwiftLingo aims to translate your entire website seamlessly, there are often cases where certain text should remain in its original language. This includes:

  • Brand Names: Your company or product name should typically not be translated.
  • Technical Terms: Specific jargon or code snippets might lose meaning if translated.
  • Proper Nouns: Names of people, places, or specific entities.
  • Untranslatable Content: Content that is intentionally in a specific language or is part of a design element.

By marking these elements with translate="no", you ensure that SwiftLingo respects your content’s integrity and delivers a more accurate and contextually appropriate translation experience for your users.

How it Works

The translate attribute is a global HTML attribute that indicates whether the content of an element should be translated when the page is localized. SwiftLingo’s translation proxy respects this standard attribute.

When SwiftLingo processes your web page for translation:

  1. Identification: The HTML parser identifies elements that have the translate="no" attribute set.
  2. Exclusion from Extraction: Any text content (including text within nested child elements) found within an element marked with translate="no" is explicitly excluded from the text sent to the translation engine.
  3. Preservation during Application: When the translated content is re-inserted into the HTML structure, the original content of elements marked with translate="no" is preserved exactly as it was, ensuring it is not overwritten by any (even accidental) translation.

This mechanism ensures that content you explicitly mark as untranslatable remains untouched throughout the entire translation pipeline.

Example Usage

To prevent a specific word or phrase from being translated, wrap it in a <span> tag (or any other inline element) and add the translate="no" attribute:

<p>
  Welcome to <span translate="no">SwiftLingo</span>, our innovative platform.
</p>

To prevent an entire block of content, including headings, paragraphs, and other elements within it, from being translated, apply the attribute to a block-level element like a <div>:

<div translate="no">
  <h1>Important Notice</h1>
  <p>This entire section contains legal disclaimers that must remain in English.</p>
  <ul>
    <li>Point 1</li>
    <li>Point 2</li>
  </ul>
</div>

Browser Support

The translate attribute is a standard HTML attribute and is widely supported by modern web browsers. While its primary function is to guide browser-based translation features, SwiftLingo leverages this standard for its server-side translation process, providing a consistent and predictable way to control content translation.

For more detailed information on the translate global attribute, refer to the MDN Web Docs.

Was this page helpful?