How to Translate alt, title, and aria-label Attributes Without Breaking Accessibility
Use attribute-aware localization to translate alt, title, and aria-label alongside visible copy. The technique applies to websites and HTML email, but the production caveat is that a translated attribute can override visible text, supply a missing accessible name, or turn an intentionally silent image into an unwanted announcement.
Decide what each element should communicate before sending strings to translation. A product photo may need a localized description, an icon-only button needs a localized action, and a decorative image needs to keep alt="" in every locale. Verify those outcomes in the rendered page, not just in the translation catalog.
Decide Which Attributes to Translate
| Markup | What to localize | What to preserve or verify |
|---|---|---|
alt="Blue backpack with two front pockets" | The visual information that matters in context. | Keep the attribute on <img>; don’t turn the text into a filename or keyword list. |
alt="" | Nothing. The empty value is intentional. | Keep alt="" present; omitting alt is not equivalent. |
aria-label="Close filters" | The control’s purpose, including any context needed to distinguish it. | Confirm the element supports naming and that the resulting name matches the visible label, if there is one. |
title="Measured from heel to toe" | The advisory text, if the attribute is retained. | Keep essential information visible. Don’t assume users can open a native tooltip. |
aria-labelledby="size-heading" | The text in the referenced element, not the attribute value. | Keep size-heading in sync with the target’s id. Preserve the order if the attribute contains multiple IDs. |
Never send
id,aria-labelledby, oraria-describedbyvalues to translators as prose. These values connect elements; localize the content at the other end of the reference.
Translate Image Alternatives According to Their Job
Write the alternative for the image’s purpose on this page. A backpack photo on a product page can identify details that shoppers compare. The same photo beside a visual-only banner may be redundant if neighboring text already conveys everything relevant. For an image that is the only content of a link, describe the link’s destination or action rather than the artwork.
<!-- Broken: a filename, a redundant badge label, and an unnamed link -->
<img src="backpack.jpg" alt="backpack-blue-v3.jpg">
<img src="star.svg" alt="Star"><span>Top rated</span>
<a href="/fr/guide-tailles">
<img src="ruler.svg" alt="">
</a>
The filename tells shoppers little, and the star adds an announcement without adding information to “Top rated.” The final link has neither text nor a named image, so it has no useful accessible name. Check image alternatives in context, including what users encounter immediately before and after each image.
<!-- Fixed: examples from a French product page -->
<img src="backpack.jpg" alt="Sac à dos bleu avec deux poches avant">
<img src="star.svg" alt=""><span>Très bien noté</span>
<a href="/fr/guide-tailles">
<img src="ruler.svg" alt="Consulter le guide des tailles">
</a>
The product image conveys a useful detail, the decorative star stays silent, and the link takes its name from the image alternative. If the link later gains visible text such as Guide des tailles, make the ruler’s alternative empty so it doesn’t repeat the label. For a chart or diagram with more detail than fits in a short alternative, put the explanation or data in nearby text.
Keep Accessible Names Aligned With Visible Labels
A text button usually gets its accessible name from its contents. On a button, aria-label overrides that text, and a valid aria-labelledby reference takes precedence over aria-label. When a translation changes only the visible label, the interface can look correct while a screen reader announces an old name or a speech-input user can’t activate the control by saying what’s on screen.
<!-- Broken: the spoken name overrides the translated button text -->
<button type="button" aria-label="Apply filters">
Appliquer les filtres
</button>
<!-- Fixed: the visible text supplies the accessible name -->
<button type="button">Appliquer les filtres</button>
<!-- Icon-only: there is no visible label to use -->
<button type="button" aria-label="Fermer les filtres">
<svg aria-hidden="true" viewBox="0 0 16 16">
<path d="M3 3l10 10M13 3L3 13" stroke="currentColor"/>
</svg>
</button>
The text button now has a single source of truth, while the icon-only button has an explicit localized name. Hiding the SVG from the accessibility tree leaves the button itself exposed. If a control with visible text needs extra context in its name, keep the visible wording intact, preferably at the start, and check the computed name in each locale.
<section aria-labelledby="delivery-heading">
<h2 id="delivery-heading">Options de livraison</h2>
<p>Choisissez une date de livraison.</p>
</section>
The section gets its name from the translated heading, so there’s no parallel label to update. Verify that the ID is unique in the rendered page, especially when the same component appears more than once. Use this pattern when the section is useful as a named landmark, not for every wrapper around a heading.
Move Essential Instructions Out of title
Browsers can show title as a hover tooltip, but keyboard and touch users can’t reliably summon it. Depending on the element and its other labels, title can also contribute a fallback accessible name or a description. Translating it doesn’t solve the discoverability problem. Put instructions in visible text and associate them with the relevant control.
<!-- Broken: the required format lives only in a tooltip -->
<label for="date-old">Date de livraison</label>
<input id="date-old" type="text" title="Format : JJ/MM/AAAA">
<!-- Fixed: the label and the format have separate jobs -->
<label for="delivery-date">Date de livraison</label>
<input id="delivery-date" type="text" aria-describedby="date-format">
<p id="date-format">Format : JJ/MM/AAAA.</p>
The visible label names the field, and the visible hint supplies its accessible description. Make the localized format match what the application accepts and what validation messages display. Avoid keeping a duplicate title on the fixed input; it can create redundant output.
Never make
titlethe only place where users can find a required format, a restriction, or instructions for completing an action.
Give Translators Context and Escape the Rendered Values
Use message keys that identify the component and the purpose, rather than routing every instance of “Close” to a single string. Include the surrounding label or a screenshot in the translation job when an image or icon is hard to identify. Keep structural values out of the catalog, including intentionally empty alternatives.
{
"product.backpack.imageAlt": "Sac à dos bleu avec deux poches avant",
"filters.closeButton.label": "Fermer les filtres",
"checkout.deliveryDate.formatHint": "Format : JJ/MM/AAAA."
}
This catalog distinguishes an image description, a button name, and a field hint. In your template, render them into alt, aria-label, and a visible text node respectively, using the framework’s normal escaping. Reject blank translations for required names, but don’t apply that rule to a decorative image’s hard-coded alt="".
<button type="button" aria-label="Fermer le panneau "Aide" & conseils">
<span aria-hidden="true">×</span>
</button>
The HTML parser decodes the character references, so the attribute’s DOM value is Fermer le panneau "Aide" & conseils. An unescaped double quote inside the quoted attribute can terminate the value early; escaping twice can leave reference text like " in the computed name. Store ordinary text in the catalog and let the renderer escape it once.
Check the Rendered Locale and the Email Output
Set the document language, such as <html lang="fr"> for French. Use a local lang only where content actually switches language; a local language declaration on a wrapper or element can also apply to its textual attributes. An attribute value can’t contain a nested <span lang="…"> to mark a language change inside the string. Where mixed-language wording needs markup, prefer visible text and test pronunciation with the screen readers your audience uses.
- Inspect the final DOM for
alt="", duplicate IDs, and stale source-language labels. Check the published build or send preview, not just the template. - In browser accessibility tools, inspect the computed
NameandDescriptionof buttons, links, and form fields. Compare each name with its visible label and each description with the visible hint. - Navigate with the keyboard and sample the locale with a screen reader. Check an icon-only control, a linked image, and any control whose name comes from
aria-labelledby. - For email, send a test to representative clients and view it with images blocked. For any critical call to action, use visible link text such as
Voir la commanderather than relying on a linked image or an ARIA attribute surviving client processing.
Use HTML Translate to compare localized attribute values with the surrounding copy before checking the computed names in the rendered page.
Common Mistakes and Troubleshooting
- A decorative image announces its filename. The localization or minification step may have dropped the empty attribute; restore
alt=""and confirm it survives publication. - A button still announces the source language. Check for a stale
aria-labelor a source-language node referenced byaria-labelledby. When visible button text is sufficient, remove the redundant override. - An image-only link is unnamed. Its nested
<img alt="">supplies no name. Add visible link text or a destination-oriented image alternative. - A localized heading no longer names its section. A changed
idor a duplicate ID may have broken the association. Compare the renderedaria-labelledbyvalue with the intended heading’s ID. - Instructions appear only on mouse hover. Move them from
titleto visible text and usearia-describedbywhen the instructions belong to a specific control. - The label stops at a quotation mark. Inspect the parsed
aria-label. Use normal template escaping instead of concatenating translated strings into HTML.
Alt, Title, Aria Questions
Should alt text be translated word for word?
No. Preserve the image’s purpose and relevant details, but phrase the alt naturally in the target language. For a functional image, prioritize what the link or button does.
Should every button have an aria-label?
No. A native <button> with clear visible text already has a name. Use aria-label when a name is needed and no suitable visible text can supply it.
Can title replace a missing image alternative?
No. Use alt for the image’s text alternative, and keep alt="" when the image is decorative. A browser’s fallback behavior for title is not a substitute for either choice.
Can aria-label go on a plain div to translate how it’s announced?
Don’t rely on it. The generic role of a plain <div> does not support naming. Use visible text for ordinary content and native semantic elements for controls.
Should product names be translated inside attributes?
Follow the same terminology rules as visible copy. Keep a protected product name unchanged inside alt or aria-label, but localize the surrounding description or action.
Is an automated accessibility check enough?
No. An automated check can catch some missing alternatives or invalid aria-labelledby references, but it can’t reliably tell whether a translation describes the right action or matches what shoppers see. Inspect the computed output and review it in context.