[WordPress] 外掛分享: Language Attribute for Container Blocks and Pages/Posts

首頁外掛目錄 › Language Attribute for Container Blocks and Pages/Posts
WordPress 外掛 Language Attribute for Container Blocks and Pages/Posts 的封面圖片
全新外掛
安裝啟用
★★★★★
5/5 分(1 則評價)
8 天前
最後更新
問題解決
WordPress 5.9+ PHP 7.2+ v3.0 上架:2025-06-29

內容簡介

此外掛旨在確保頁面內容中的語言變更能在容器區塊層級被標示,以協助輔助技術符合 WCAG 指導方針,提升網站的可及性。

【主要功能】
• 支援容器區塊層級的語言設定
• 兼容區塊編輯器與經典編輯器
• 可直接在文件設定側邊欄修改 HTML lang 和 dir 屬性

外掛標籤

開發者團隊

⬇ 下載最新版 (v3.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Language Attribute for Container Blocks and Pages/Posts」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

This plugin aims to ensure that any language change in a page’s content is indicated to assistive technologies at the container block level, helping a website comply with WCAG guidelines.
This feature is available on the core block editor only at a text formatting level after code from Jb Audras plugin “Lang Attribute for the Block Editor” was merged into core. The objective of this plugin is to provide the same functionality at a container block level (Group – including all its variants, Columns, Cover, and other specific block types) so that the language applies to all child elements, no matter the kind of content inside.
The plugin also supports setting the language at the page or post level, both on the blocks and classic editor. When an entire page is written in a different language than the website’s default, you can override the HTML lang and dir attributes for that specific page directly from the Document Settings sidebar, without needing to wrap everything in a container block.
This plugin is heavily inspired by the Jb Audras plugin (including this readme file). The development started at WordCamp Europe 2025 Contributor Day, by Marco Almeida from Naked Cat Plugins / Webdados, and the help from Ryan Welcher on the code side and Amber Hinds on the accessibility compliance side.
For more context: this plugin helps you to make your website compliant with the Web Content Accessibility Guidelines (WCAG) success criteria:

3.1.1 – Language of Page: The default human language of each web page can be programmatically determined. Use the page-level setting when an entire page or post is written in a language other than the website’s default.
3.1.2 – Language of Parts: The human language of each passage or phrase in the content can be programmatically determined. Use the block-level setting when only specific sections within a page are in a different language.

The purpose of these success criteria is to ensure that user agents can correctly present content written in multiple languages.
Keep in mind that you should set the lang and dir attributes only on a container block or page if the content is written in a language different from the one set globally on your website.
As per Web Content Accessibility Guidelines:
This enables user agents and assistive technologies to present content according to the presentation and pronunciation rules of that language. This applies to graphical browsers, screen readers, braille displays, and other voice browsers.
Both assistive technologies and conventional user agents can render text more accurately if the language of each passage of text is identified. Screen readers can use the language’s pronunciation rules. Visual browsers can display characters and scripts appropriately.
This is especially important when switching between languages that read from left to right and languages that read from right to left, or when text is rendered in a language that uses a different alphabet. Users with disabilities who know all the languages used in the Web page will be better able to understand the content when each passage is rendered appropriately.
That’s not just good for accessibility. It’s also great for SEO. Search engines like Google can better understand your content when languages are clearly defined. That means improved indexing and potentially better rankings.
Banner photo by Hannah Wright.
Supported block types

Group (core/group): Group contents together and set a language for them
Columns (core/columns and core/column): Organize content into a set of columns and set a language for all the columns or a specific column
Cover (core/cover): Set the language to all the contents inside a cover block
Navigation (core/navigation): Create full navigation menus in different languages
Submenu (core/navigation-submenu): Set a different language on a sub-section of your menu (for example, if you have the default language pages on the first level and a sub-menu with pages in another language)
Page List (core/page-list): List all the pages on your website that are written in a different language and created as a child of the main page of that language
Content (core/post-content): Set the post content on a custom template to a different language

Features

Set the language and text direction for an entire page or post, both on the blocks and classic editor: a “Page Language” panel in the Document Settings sidebar overrides the HTML lang and dir attributes for that specific page
Add lang and dir attributes to Group, Columns, Cover, and other specific WordPress Blocks, mentioned above
Show visual outline around blocks that have a language attribute set – For easy identification of blocks you have already set to a different language during your editing process, only for Administrators and Editors, and if enabled in Settings – Writing

延伸相關外掛

文章
Filter
Apply Filters
Mastodon