<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[HTML Translate]]></title><description><![CDATA[HTML Translate]]></description><link>https://htmltranslate.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 26 Nov 2026 11:15:42 GMT</lastBuildDate><atom:link href="https://htmltranslate.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[HTML translate="no" vs class="notranslate": What Actually Works Across Parsers]]></title><description><![CDATA[Your page marks a product name with class="notranslate", but the translation job returns it in another language. The HTML parser kept the class exactly as…]]></description><link>https://htmltranslate.hashnode.dev/html-translate-no-vs-class-notranslate-what-actually-works-across-parsers</link><guid isPermaLink="true">https://htmltranslate.hashnode.dev/html-translate-no-vs-class-notranslate-what-actually-works-across-parsers</guid><category><![CDATA[HTML]]></category><category><![CDATA[webdev]]></category><category><![CDATA[i18n]]></category><category><![CDATA[frontend]]></category><dc:creator><![CDATA[Aleksey Kulakov]]></dc:creator><pubDate>Wed, 25 Nov 2026 12:42:30 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6873a27ad3fa41d66d835257/43608311-e33a-43ba-af50-1791e487fe0a.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Your page marks a product name with <code>class="notranslate"</code>, but the translation job returns it in another language. The HTML parser kept the class exactly as written; the extraction tool simply had no rule for interpreting it.</p>
<h2>Problem</h2>
<p><code>class="notranslate"</code> is a convention, not an HTML translation instruction. Browsers do not treat that class as a request to preserve text, and HTML itself assigns it no special meaning. A translation pipeline can choose to recognize it, but another pipeline—or a different configuration of the same one—may ignore it.</p>
<p>The global <code>translate</code> attribute has a different status. HTML defines its values and inheritance: <code>translate="no"</code> marks an element and its descendants as not to be translated; <code>translate="yes"</code> explicitly opts an element back into translation. An element without a valid explicit value inherits its parent’s mode, with translation as the default at the root.</p>
<p>That distinction matters at multiple stages. A parser can preserve either a class or an attribute without applying translation rules. A browser can expose HTML’s translation intent without translating the page itself. An extraction pipeline must then decide whether it reads the standard attribute, applies its own class rules, strips markup before extraction, or segments text in a way that loses the element boundaries.</p>
<p>If you rely only on the class, you are relying on a tool-specific contract. If you use the HTML attribute, you express standard HTML intent—but you still need to check that the particular pipeline honors it. The <a href="https://htmltranslate.com/blog/html-translate-no-attribute">walkthrough of the HTML translate attribute</a> covers its markup behavior; the production question here is whether your actual extraction path preserves and applies that behavior.</p>
<pre><code class="language-html">&lt;p&gt;Open &lt;span class="notranslate"&gt;Northstar Sync&lt;/span&gt; to review your backups.&lt;/p&gt;

&lt;p&gt;Open &lt;span translate="no"&gt;Northstar Sync&lt;/span&gt; to review your backups.&lt;/p&gt;
</code></pre>
<p>The first version works only when the translation tool has an explicit rule for <code>notranslate</code>. The second communicates the intent in HTML, but a pipeline that does not inspect the attribute can still translate the name. Neither spelling guarantees the result across every parser and service.</p>
<blockquote>
<p>Do not treat a class name as a cross-tool translation contract unless you have verified that each production pipeline recognizes it.</p>
</blockquote>
<h2>Fix</h2>
<p>Use <code>translate="no"</code> for the standard signal, scoped to the smallest element that contains the literal. Keep a class as well only when a specific tool, stylesheet, or integration requires it. That gives standards-aware consumers meaningful HTML while preserving compatibility with a known class-based consumer.</p>
<pre><code class="language-html">&lt;p&gt;
  Open
  &lt;span translate="no" class="notranslate"&gt;Northstar Sync&lt;/span&gt;
  to review your backups.
&lt;/p&gt;
</code></pre>
<p>Do not assume that adding <code>translate="yes"</code> will override every <code>notranslate</code> class rule. The HTML attribute has defined inheritance semantics; the class does not. A pipeline that excludes a matching class may apply its own ancestor or element-level behavior, independent of HTML’s rules. Test the exact markup against the configured service rather than inferring behavior from a browser preview.</p>
<p>A useful check is to send a small fixture through the same route used for production: source HTML, parser or sanitizer, extraction, translation, and reinsertion. Include a protected term inside an ordinary sentence, plus a translated child inside a <code>translate="no"</code> parent if your content uses that pattern. Inspect the extracted units as well as the final rendered page. If the attribute disappears before extraction, fixing the template alone will not solve the pipeline problem.</p>
<p>Also check the tool’s handling of translatable attributes and accessibility text. HTML translation intent can apply beyond visible text, while a vendor’s class rule may cover only the text nodes it extracts. The <a href="https://htmltranslate.com/blog/which-html-attributes-should-be-translated">reference on which HTML attributes should be translated</a> is useful when you need to define that boundary.</p>
<blockquote>
<p>Validate translation behavior in the production extraction pipeline. A browser rendering the page correctly is not evidence that a translation service honored the markup.</p>
</blockquote>
<p>The practical choice is not “attribute or class everywhere.” Use the standard attribute to express HTML intent; add a tool-specific class only for a verified integration requirement. That keeps your markup interpretable without pretending every translation system shares the same conventions.</p>
]]></content:encoded></item><item><title><![CDATA[CI/CD Check for Localized Static API Docs: Catching Broken IDs and Mutated Code Blocks]]></title><description><![CDATA[Your localized API page can look correct in a browser and still ship a request example with a translated parameter—or a navigation link that points to an…]]></description><link>https://htmltranslate.hashnode.dev/ci-cd-check-for-localized-static-api-docs-catching-broken-ids-and-mutated-code-blocks</link><guid isPermaLink="true">https://htmltranslate.hashnode.dev/ci-cd-check-for-localized-static-api-docs-catching-broken-ids-and-mutated-code-blocks</guid><category><![CDATA[Python]]></category><category><![CDATA[documentation]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Aleksey Kulakov]]></dc:creator><pubDate>Wed, 25 Nov 2026 12:37:52 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6873a27ad3fa41d66d835257/ce6f9427-3890-4319-8016-b84697f6ff32.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Your localized API page can look correct in a browser and still ship a request example with a translated parameter—or a navigation link that points to an ID that no longer exists. Neither failure needs a runtime test: both are detectable in CI before the page is deployed.</p>
<h2>Problem</h2>
<p>Localization changes the text around API examples, but code blocks and fragment targets often need to stay stable. A translation pass can alter a token inside a <code>&lt;pre&gt;</code> without making the page visibly broken. Separately, a translated heading may keep its visible meaning while its <code>id</code> changes, leaving an existing same-page link stranded.</p>
<p>Visual review is a weak check for both cases. It won’t reliably catch a changed character in a request, and it can miss a broken fragment if nobody clicks that exact link. The fix is to compare the parsed HTML content in CI, where you can check every localized page on every change.</p>
<p>Keep the check narrow: compare code-block text to the canonical page, verify document IDs and same-page fragments, and require a clear no-translation boundary on each code block. The <a href="https://htmltranslate.com/blog/translate-html-documentation">full walkthrough on localizing HTML documentation</a> covers the surrounding content decisions; this check focuses on catching regressions in the built pages.</p>
<h2>Fix</h2>
<p>Run a static check against each locale’s corresponding canonical HTML page. The example below uses Beautiful Soup to parse both documents. It compares each <code>&lt;pre&gt;</code> block’s parsed text exactly—no trimming or whitespace collapsing—because whitespace inside examples may matter. Pin the parser as a development dependency so CI uses a predictable version.</p>
<pre><code class="language-python">from pathlib import Path
from urllib.parse import unquote

from bs4 import BeautifulSoup


def validate(page_path, canonical_path):
    page = BeautifulSoup(Path(page_path).read_text(), "html.parser")
    canonical = BeautifulSoup(Path(canonical_path).read_text(), "html.parser")
    errors = []

    actual = page.find_all("pre")
    expected = canonical.find_all("pre")
    for n in range(max(len(actual), len(expected))):
        if n &gt;= len(actual) or n &gt;= len(expected):
            errors.append(f"CODE_BLOCK_MUTATED: {page_path} block={n + 1}")
            continue
        if actual[n].get_text() != expected[n].get_text():
            errors.append(f"CODE_BLOCK_MUTATED: {page_path} block={n + 1}")
        if actual[n].get("translate", "").lower() != "no":
            errors.append(f"MISSING_TRANSLATE_NO: {page_path} block={n + 1}")

    ids = [tag["id"] for tag in page.find_all(attrs={"id": True})
           if tag["id"]]
    for value in set(ids):
        if ids.count(value) &gt; 1:
            errors.append(f"DUPLICATE_ID: {page_path} id={value}")

    targets = set(ids)
    for tag in page.find_all("a", href=True):
        href = tag["href"]
        if href.startswith("#"):
            target = unquote(href[1:])
            if not target or target not in targets:
                errors.append(
                    f"BROKEN_FRAGMENT: {page_path} href={href} target={target}"
                )
    return errors
</code></pre>
<p>Call <code>validate</code> for every locale-to-canonical page pair in your build, collect the returned errors, and exit nonzero if the list is not empty. The block numbering is one-based so a failure points to the block as a person would count it. If your repository uses a different error format, keep the same information: page, block or target, and failure type.</p>
<p>The check deliberately requires <code>translate="no"</code> on the <code>&lt;pre&gt;</code> itself. That is a simple project convention: it makes the protection visible at the boundary of each example and avoids relying on an ancestor’s state. If your markup allows inherited translation settings instead, adapt the check to walk the ancestors and determine the effective state; don’t treat an absent attribute on <code>&lt;pre&gt;</code> as proof that the block is protected.</p>
<blockquote>
<p>Production rule: compare parsed code text exactly unless you have explicitly defined a safe normalization. Silently collapsing whitespace can hide a changed command or example.</p>
</blockquote>
<p>Check non-empty IDs for duplicates within each document, then resolve every same-page fragment against that document’s ID set. The example decodes percent-encoded fragment text before comparison. It intentionally doesn’t try to validate links to other pages; those need a site-wide link check and are a separate failure class.</p>
<p>Run this after localization output is generated and before deployment, not only against source templates. That is the HTML your readers will copy from and the browser will navigate. Keep the canonical snippet source under version control, and review changes to it as API-example changes—not as translation edits. You can adapt the same CI pattern from the <a href="https://github.com/htmltranslate/check-translation">translation-checker repository</a> to fit your page mapping and build commands.</p>
<p>When the check fails, treat it as a release blocker until someone confirms the intended change and updates the canonical source or localized markup. That keeps a locale from quietly becoming a different API reference than the one you tested.</p>
]]></content:encoded></item></channel></rss>