Check 27.02 · Development and accessibility by language

Mark passages in another language

Find quotations, titles and language names written in another language and mark them up with lang in WordPress, Drupal, Shopify, Laravel or Next.js.

Priority
Important
Difficulty
Easy
Estimated time
1 to 3 h
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

When a passage is written in a different language from the rest of the page (a quotation in English, a German title of a work, the language names in the switcher), the element that contains it must carry its own lang attribute: <blockquote lang="en">. The task is to find these passages in the templates and the content, mark them up with the right value, and give writers a way to do it in their editor. Once it is done, every change of language is announced to screen readers and to the browser.

Why it matters

A screen reader reads all the text with the pronunciation rules of the language declared on <html>. Without markup, “Customer success stories” in a French page is pronounced the French way, and the name “Deutsch” in the language switcher becomes unrecognizable. WCAG success criterion 3.1.2 “Language of Parts” (level AA) requires that the language of each passage can be programmatically determined.

The W3C allows exceptions: proper names, technical terms, words of indeterminate language and words that have become part of the page language's vocabulary (“week-end”, “marketing” in French). For these, markup is allowed but not required.

The attribute also affects rendering: correct hyphenation of the passage, quotation marks generated by CSS, language-specific glyphs in fonts that contain several variants, and language-sensitive case changes.

On the search engine side, Google determines the language of a page from its visible content and documents no use of lang on passages. This markup is therefore not a ranking lever. Nor does it replace translation: a French page containing whole paragraphs left in English is still a mixed page, see avoid mixed-language pages with partial translations (opens in a new tab).

What it improves

  • Accessibility Correct pronunciation of foreign passages by screen readers and braille displays; compliance with WCAG criterion 3.1.2.
  • Language switcher Each language name is read correctly, which makes switching language usable for blind people.
  • Rendering Hyphenation and typography suited to the passage.
  • Browser machine translation A correctly marked-up passage is better identified. The effect varies by browser.
  • Rankings and generative engines No documented effect.

How to check

Inventory of passages already marked up. In the browser console, on a page:

console.table([...document.querySelectorAll('body [lang]')].map((el) => ({
  tag: el.tagName,
  lang: el.getAttribute('lang'),
  text: el.textContent.trim().slice(0, 60),
})))

Expected result: one row per foreign passage, with a valid value (en, de, es), and at least one row per language in the switcher.

Valid values. Lighthouse, Accessibility category, and axe flag lang attributes whose value is not a valid language tag (lang="english", lang="en_US").

Missed passages. No tool detects them reliably: the check is editorial. Go through one page of each template and look for the items in the table in the next section. To be sure of the result, listen to the page with a screen reader (VoiceOver on macOS, NVDA on Windows): a passage with wrong markup is immediately audible.

Across the whole site. In Screaming Frog, a custom search for words typical of the foreign language (“the”, “and”, “with” on a French site) in the HTML, combined with the XPath extraction //*[@lang and not(self::html)]/@lang, lets you compare the pages that contain English with those that mark it up.

How to implement

Before you start

What to mark up, and how:

Case Markup example Required?
Language names in the switcher <a href="/de/" hreflang="de" lang="de">Deutsch</a> Yes
Quotation in another language <blockquote lang="en">…</blockquote> Yes
Title of a work, slogan, untranslated expression <cite lang="de">Die Verwandlung</cite>, <span lang="en">Think different</span> Yes
Customer testimonial left in its original language <figure lang="es">…</figure> Yes
Borrowed word in common use (“week-end” in French) None No
Proper name, brand (“Google”, “Albert Camus”) None No
Computer code, identifiers <code translate="no"> No (translate="no" prevents machine translation)
Passage in Arabic or Hebrew <span lang="ar" dir="rtl">…</span> or <bdi lang="ar">…</bdi> Yes

Three rules:

  • Put lang on the closest element that wraps exactly the passage. For a few words in the middle of a sentence, a <span> is enough.
  • The page language comes back automatically: everything outside the element inherits the language of <html>. There is no need to set lang="fr" again elsewhere.
  • Do not confuse lang and hreflang: on a link, hreflang="de" describes the language of the target page, lang="de" the language of the link text. In a switcher, use both.

Find the passages

Draw up the list by template, then by piece of content:

  1. Templates: language switcher, footer (notices in English, certification names), cookie banner from a third-party tool left in English, share buttons, review widgets.
  2. Editorial content: quotations, testimonials, international case studies, book titles, brand taglines.
  3. Product pages: product line names or slogans kept in their original language.

For each item found, note the URL, the passage, the language and the person who fixes it. Strings left untranslated by mistake belong to another task: detect untranslated strings (opens in a new tab).

WordPress

Versions WordPress 6.4 and later, block editor; Polylang 3, WPML 4 and 5.

Block editor. Since WordPress 6.3, a “Language” format is built in: select the passage, open the drop-down menu of the formatting toolbar (the arrow next to the link options) and choose “Language”, then enter the code (en) and the text direction. The editor wraps the passage in a <bdo lang="en" dir="ltr">. This tag enforces the chosen direction: keep “Left to right” for English and choose “Right to left” for Arabic or Hebrew. The “Lang Attribute for the Block Editor” plugin, whose code has been merged into core, is no longer needed.

Whole block. For a complete quotation, open the block menu (three dots), “Edit as HTML”, and add the attribute to the tag: <blockquote class="wp-block-quote" lang="en">. Switch back to visual mode: the attribute is kept.

Classic editor. “Text” tab, then type the <span lang="en"> by hand.

Language switcher. Polylang and WPML write language names in their own language; check in the source code that each link carries lang. If not, override the switcher template in your child theme.

Drupal

Versions Drupal 10 and 11, CKEditor 5.

CKEditor 5 has a “Language” button. Open Configuration > Content authoring > Text formats and editors (/admin/config/content/formats), edit the format in use (Full HTML, Basic HTML), drag the button into the active toolbar, choose the list of languages offered in its settings, then save. If Drupal reports that the <span> element is not allowed, add <span lang dir> to the allowed tags in the format's source editing settings.

Shopify

Versions Shopify admin and Online Store 2.0 themes, all plans, November 2026.

The rich text editor for products, collections, pages and blog posts has a “Show HTML” button (<>). Switch to HTML and wrap the passage: <span lang="en">…</span>. For the theme's text (language switcher, footer), edit the files in the sections/ or snippets/ folder in Online Store > Themes > … > Edit code. In the loop over localization.available_languages, the name of each language in its own language is language.endonym_name; add lang="{{ language.iso_code }}" to its link.

Webflow

Versions Webflow Designer, November 2026.

Select the element, open the Element settings panel, Custom attributes section, and add lang with the value en. For a few words in the middle of rich text, use a code embed element containing the <span lang="en">.

Laravel

Versions Laravel 11 to 13.

In Blade views, mark up directly:

<blockquote lang="{{ $testimonial->language }}">
    {{ $testimonial->body }}
</blockquote>

For content stored in the database that may be in a different language from the page (reviews, testimonials), add a language column to the table and use it in the template. In the switcher, loop over the supported languages:

@foreach(config('app.supported_locales') as $locale)
    <a href="{{ route('home', ['locale' => $locale]) }}" hreflang="{{ $locale }}" lang="{{ $locale }}">
        {{ __("languages.{$locale}", locale: $locale) }}
    </a>
@endforeach

The locale parameter of __() displays each language's name in that language. To point to the equivalent page rather than the homepage, see link to the equivalent page rather than the homepage (opens in a new tab).

Next.js

Versions Next.js 15 and 16 (App Router), next-intl 4.

In JSX, the attribute is written as is: <blockquote lang="en">. For a passage inside a translated string, an internationalization library that handles rich text avoids splitting the sentence. With next-intl:

t.rich('temoignage', {
  en: (chunks) => <span lang="en">{chunks}</span>,
})

with, in the French translation file, "temoignage": "Notre client résume : <en>It just works</en>."

Astro

Versions Astro 5 to 7.

In Markdown or MDX files, inline HTML is accepted, as in this French sentence: Notre devise interne, <span lang="en">Ship it</span>, résume l'esprit de l'équipe. In .astro components, mark up as in HTML.

Common mistakes

  • Language switcher not marked up: it is the most frequent foreign passage on the site and the one most often forgotten.
  • Invalid value: lang="english", lang="en_US", lang="uk" for British English (uk is Ukrainian; use en-GB).
  • Attribute on too wide an element: lang="en" set on a whole section that also contains French.
  • Marking up common words: “marketing” or “email” marked lang="en" in a French text, which makes them pronounced with a needless foreign accent.
  • Thinking markup removes the need to translate: a paragraph accidentally left in English must be translated, not marked up.
  • Forgetting text direction: a passage in Arabic in a French page without dir="rtl" or <bdi> is displayed with misplaced punctuation.

Frequently asked questions

Should you mark up every English word in a French text?

No. WCAG criterion 3.1.2 excludes words that have become part of the page language's vocabulary, such as week-end or marketing in French, as well as proper names and technical terms. Mark up genuinely foreign passages: quotations, slogans kept in their original language, titles of works, untranslated testimonials and the language names in the switcher. A simple test is to ask whether a French speaker would pronounce the word the English way.

Does the lang attribute on a passage have an SEO effect?

No documented effect. Google determines the language of a page from its visible content and describes no use of the lang attribute set on a passage. This markup serves accessibility: screen readers switch pronunciation for that passage only, then return to the page language. It also improves hyphenation and typography. It does not turn a poorly translated page into a correct one.

How do you mark up the language names in a switcher?

Write each language name in its own language, Deutsch rather than German, and add to its link the lang attribute with that language's code, for example lang="de". Also add hreflang="de", which describes the language of the target page. The screen reader then pronounces each name correctly. Polylang, WPML and most internationalization libraries allow this; check the result in the source code.

What is the difference between WCAG criteria 3.1.1 and 3.1.2?

Criterion 3.1.1, level A, covers the main language of the page, declared by the lang attribute of the html tag. Criterion 3.1.2, level AA, covers passages written in another language, which must carry their own lang attribute. A site subject to a level AA compliance requirement must meet both. The second depends mostly on writers, which is why it helps to give them the tool in the editor.

Updated on

Topic checklist (PDF)

And now?

In the “Development and accessibility by language” topic

  1. Set html lang on each page
  2. Mark passages in another language
  3. Use UTF-8
  4. Handle accents and non-Latin scripts
  5. Handle dir=rtl if needed
  6. Check fonts for each language
  7. Test for text overflow
  8. Test performance for each version
  9. Test SSR/SSG for all languages
  10. Test multilingual dynamic routes
  11. Check per-language cache handling
  12. Check the CDN and language variants
  13. Serve the right content at the requested URL
  14. Test without cookies
  15. Test without Accept-Language
  16. Test keyboard navigation of the language switcher