{"id":238574,"date":"2025-06-30T08:05:27","date_gmt":"2025-06-30T08:05:27","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/language-attribute-for-container-blocks\/"},"modified":"2026-03-09T12:13:50","modified_gmt":"2026-03-09T12:13:50","slug":"lang-attribute-blocks","status":"publish","type":"plugin","link":"https:\/\/km.wordpress.org\/plugins\/lang-attribute-blocks\/","author":23274606,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"3.0","stable_tag":"3.0","tested":"7.0","requires":"5.9","requires_php":"7.2","requires_plugins":null,"header_name":"Language Attribute for Container Blocks and Pages\/Posts","header_author":"Naked Cat Plugins (by Webdados)","header_description":"Add \"lang\" and \"dir\" attributes on Group and Columns WordPress Blocks","assets_banners_color":"655c54","last_updated":"2026-03-09 12:13:50","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"","header_author_uri":"https:\/\/nakedcatplugins.com","rating":5,"author_block_rating":0,"active_installs":0,"downloads":678,"num_ratings":1,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":{"1.0":{"tag":"1.0","author":"nakedcatplugins","date":"2025-06-30 11:16:34"},"1.1":{"tag":"1.1","author":"nakedcatplugins","date":"2025-06-30 11:16:34"},"1.2":{"tag":"1.2","author":"nakedcatplugins","date":"2025-07-25 10:57:49"},"2.0":{"tag":"2.0","author":"nakedcatplugins","date":"2025-08-01 16:36:18"},"2.1":{"tag":"2.1","author":"nakedcatplugins","date":"2025-08-09 13:38:09"},"2.2":{"tag":"2.2","author":"nakedcatplugins","date":"2025-10-20 16:54:32"},"3.0":{"tag":"3.0","author":"nakedcatplugins","date":"2026-03-09 12:13:50"}},"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":1},"assets_icons":{"icon.svg":{"filename":"icon.svg","revision":3381444,"resolution":false,"location":"assets","locale":false}},"assets_banners":{"banner-1544x500.jpg":{"filename":"banner-1544x500.jpg","revision":3381444,"resolution":"1544x500","location":"assets","locale":""},"banner-772x250.jpg":{"filename":"banner-772x250.jpg","revision":3381444,"resolution":"772x250","location":"assets","locale":""}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0","1.1","1.2","2.0","2.1","2.2","3.0"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":3381444,"resolution":"1","location":"assets","locale":""},"screenshot-2.png":{"filename":"screenshot-2.png","revision":3381444,"resolution":"2","location":"assets","locale":""},"screenshot-3.png":{"filename":"screenshot-3.png","revision":3381444,"resolution":"3","location":"assets","locale":""}},"screenshots":{"1":"Using the block editor to add a language attribute to a Group block","2":"The <code>lang<\/code> and `dir attributes rendered on the frontend","3":"Using the highlighting option during the editing process"},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[1953,148857,155767,148076,1385],"plugin_category":[34,48],"plugin_contributors":[240703,78419],"plugin_business_model":[],"class_list":["post-238574","plugin","type-plugin","status-publish","hentry","plugin_tags-accessibility","plugin_tags-block-editor","plugin_tags-classic-editor","plugin_tags-gutenberg","plugin_tags-language","plugin_category-accessibility","plugin_category-language-tools","plugin_contributors-nakedcatplugins","plugin_contributors-webdados","plugin_committers-nakedcatplugins","plugin_committers-webdados"],"banners":{"banner":"https:\/\/ps.w.org\/lang-attribute-blocks\/assets\/banner-772x250.jpg?rev=3381444","banner_2x":"https:\/\/ps.w.org\/lang-attribute-blocks\/assets\/banner-1544x500.jpg?rev=3381444","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":"https:\/\/ps.w.org\/lang-attribute-blocks\/assets\/icon.svg?rev=3381444","icon":"https:\/\/ps.w.org\/lang-attribute-blocks\/assets\/icon.svg?rev=3381444","icon_2x":false,"generated":false},"screenshots":[{"src":"https:\/\/ps.w.org\/lang-attribute-blocks\/assets\/screenshot-1.png?rev=3381444","caption":"Using the block editor to add a language attribute to a Group block"},{"src":"https:\/\/ps.w.org\/lang-attribute-blocks\/assets\/screenshot-2.png?rev=3381444","caption":"The <code>lang<\/code> and `dir attributes rendered on the frontend"},{"src":"https:\/\/ps.w.org\/lang-attribute-blocks\/assets\/screenshot-3.png?rev=3381444","caption":"Using the highlighting option during the editing process"}],"raw_content":"<!--section=description-->\n<p>This plugin aims to ensure that any language change in a page\u2019s content is indicated to assistive technologies at the container block level, helping a website comply with WCAG guidelines.<\/p>\n\n<p>This feature is available on the core block editor only at a text formatting level after code from <a href=\"https:\/\/wordpress.org\/plugins\/lang-attribute\/\">Jb Audras plugin \u201cLang Attribute for the Block Editor\u201d<\/a> 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.<\/p>\n\n<p>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\u2019s default, you can override the HTML <code>lang<\/code> and <code>dir<\/code> attributes for that specific page directly from the Document Settings sidebar, without needing to wrap everything in a container block.<\/p>\n\n<p>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 <a href=\"https:\/\/profiles.wordpress.org\/nakedcatplugins\/\">Naked Cat Plugins<\/a> \/ <a href=\"https:\/\/profiles.wordpress.org\/webdados\/\">Webdados<\/a>, and the help from <a href=\"https:\/\/profiles.wordpress.org\/welcher\/\">Ryan Welcher<\/a> on the code side and <a href=\"https:\/\/profiles.wordpress.org\/alh0319\/\">Amber Hinds<\/a> on the accessibility compliance side.<\/p>\n\n<p>For more context: this plugin helps you to make your website compliant with the Web Content Accessibility Guidelines (WCAG) success criteria:<\/p>\n\n<ul>\n<li><strong>3.1.1 \u2013 Language of Page<\/strong>: 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\u2019s default.<\/li>\n<li><strong>3.1.2 \u2013 Language of Parts<\/strong>: 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.<\/li>\n<\/ul>\n\n<p>The purpose of these success criteria is to ensure that user agents can correctly present content written in multiple languages.<\/p>\n\n<p>Keep in mind that you should set the <code>lang<\/code> and <code>dir<\/code> 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.<\/p>\n\n<p><strong>As per Web Content Accessibility Guidelines:<\/strong><\/p>\n\n<p>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.<\/p>\n\n<p>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\u2019s pronunciation rules. Visual browsers can display characters and scripts appropriately.<\/p>\n\n<p>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.<\/p>\n\n<p>That\u2019s not just good for accessibility. It\u2019s 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.<\/p>\n\n<p>Banner photo by <a href=\"https:\/\/unsplash.com\/@hannahwrightdesigner?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash\">Hannah Wright<\/a>.<\/p>\n\n<h3>Supported block types<\/h3>\n\n<ul>\n<li><strong>Group<\/strong> (<code>core\/group<\/code>): Group contents together and set a language for them<\/li>\n<li><strong>Columns<\/strong> (<code>core\/columns<\/code> and <code>core\/column<\/code>): Organize content into a set of columns and set a language for all the columns or a specific column<\/li>\n<li><strong>Cover<\/strong> (<code>core\/cover<\/code>): Set the language to all the contents inside a cover block<\/li>\n<li><strong>Navigation<\/strong> (<code>core\/navigation<\/code>): Create full navigation menus in different languages<\/li>\n<li><strong>Submenu<\/strong> (<code>core\/navigation-submenu<\/code>): 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)<\/li>\n<li><strong>Page List<\/strong> (<code>core\/page-list<\/code>): 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<\/li>\n<li><strong>Content<\/strong> (<code>core\/post-content<\/code>): Set the post content on a custom template to a different language<\/li>\n<\/ul>\n\n<h3>Features<\/h3>\n\n<ul>\n<li>Set the language and text direction for an entire page or post, both on the blocks and classic editor: a \u201cPage Language\u201d panel in the Document Settings sidebar overrides the HTML <code>lang<\/code> and <code>dir<\/code> attributes for that specific page<\/li>\n<li>Add <code>lang<\/code> and <code>dir<\/code> attributes to Group, Columns, Cover, and other specific WordPress Blocks, mentioned above<\/li>\n<li>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<\/li>\n<\/ul>\n\n<!--section=installation-->\n<ol>\n<li>Install the plugin and activate it.<\/li>\n<li>To set the language for an entire page or post: open the Document Settings sidebar (the panel icon at the top right of the editor) and use the \u201cPage Language\u201d panel.<\/li>\n<li>To set the language for a specific section within a page: insert a Group, Columns, Cover (or other specific) block, and use the \u201cBlock Language\u201d sidebar panel to set the language for all the content inside that container.<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt id=\"when%20should%20i%20use%20the%20page-level%20language%20setting%20instead%20of%20a%20block-level%20one%3F\"><h3>When should I use the page-level language setting instead of a block-level one?<\/h3><\/dt>\n<dd><p>Use the <strong>Page Language<\/strong> setting (in the Document Settings sidebar) when the entire page or post is written in a different language than the website default. This overrides the <code>lang<\/code> attribute on the HTML element itself, which corresponds to WCAG 3.1.1 (Language of Page).\nIn this case, we also recommend creating a dedicated template in the Site Editor (Appearance \u2192 Editor \u2192 Templates) where shared template parts \u2014 such as the header and footer \u2014 are also in that same language.<\/p>\n\n<p>Use the <strong>Block Language<\/strong> setting (in the block\u2019s sidebar panel) when only a specific section within a page is in a different language, while the rest of the page remains in the site\u2019s default language. This corresponds to WCAG 3.1.2 (Language of Parts).<\/p><\/dd>\n<dt id=\"why%20not%20have%20the%20option%20to%20set%20the%20language%20attribute%20on%20all%20block%20types%3F\"><h3>Why not have the option to set the language attribute on all block types?<\/h3><\/dt>\n<dd><p>The idea is to keep it simple and help content and website editors set different language sections, with as many child-blocks as they want, instead of setting it block by block.<\/p><\/dd>\n<dt id=\"is%20it%20possible%20to%20change%20the%20highlight%20color%3F%20the%20default%20red%20is%20not%20suitable%20for%20my%20website%20background%20color.\"><h3>Is it possible to change the highlight color? The default red is not suitable for my website background color.<\/h3><\/dt>\n<dd><p>Yes. Use the <code>nakedcatplugins_lang_attr_highlight_color<\/code> PHP filter and return the color you want.\nHere\u2019s a <a href=\"https:\/\/gist.github.com\/webdados\/61197dd2e98f399ba2cfeefbac518851\">Gist example<\/a>.<\/p>\n\n<p>If your are working on a WordCamp website, or you don\u2019t want to mess around with PHP, you can also add custom CSS to change the color, overriding our <code>--nakedcatplugins-lang-attr-highlight-color<\/code> variable.\nHere\u2019s a <a href=\"https:\/\/gist.github.com\/webdados\/7179f5be4e224ba84867cf77e9bc9174\">Gist example<\/a>.<\/p><\/dd>\n<dt id=\"how%20can%20i%20contribute%20to%20this%20plugin%3F\"><h3>How can I contribute to this plugin?<\/h3><\/dt>\n<dd><p><a href=\"https:\/\/github.com\/webdados\/lang-attribute-blocks\">On GitHub<\/a><\/p><\/dd>\n<dt id=\"how%20can%20i%20report%20security%20bugs%3F\"><h3>How can I report security bugs?<\/h3><\/dt>\n<dd><p>You can report security bugs through the Patchstack Vulnerability Disclosure Program. The Patchstack team helps validate, triage, and handle any security vulnerabilities. <a href=\"https:\/\/patchstack.com\/database\/vdp\/ce04f590-44d9-45f3-9411-9028e87d4725\">Report a security vulnerability.<\/a><\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>3.0 - 2026-03-09<\/h4>\n\n<ul>\n<li>[NEW] Plugin renamed from \u201cLanguage Attribute for Container Blocks\u201d to \u201cLanguage Attribute for Container Blocks and Pages\/Posts\u201d<\/li>\n<li>[NEW] Set the page\/post language at the document level: a new \u201cPage Language\u201d panel in the Document Settings sidebar allows overriding the HTML <code>lang<\/code> and <code>dir<\/code> attributes for a specific page or post, independently of the website\u2019s default language<\/li>\n<li>[TWEAK] Rename \u201cLanguage Settings\u201d sidebar block panel to \u201cBlock Language\u201d<\/li>\n<li>[FIX] Gist URL for changing the highlight color using plain CSS<\/li>\n<li>[DEV] Tested up to 7.0-beta3-61865<\/li>\n<\/ul>\n\n<h4>2.2 - 2025-10-20<\/h4>\n\n<ul>\n<li>[DEV] Implement deployment actions on GitHub<\/li>\n<li>[DEV] Update phpcs rules file<\/li>\n<\/ul>\n\n<h4>2.1 - 2025-08-09<\/h4>\n\n<ul>\n<li>[NEW] Support for the Content block type<\/li>\n<li>[FIX] Apply the attribute to the correct Group block tag when it\u2019s not a DIV<\/li>\n<\/ul>\n\n<h4>2.0 - 2025-08-01<\/h4>\n\n<ul>\n<li>[NEW] Support for new block types: Navigation, Submenu, and Page List<\/li>\n<li>[DEV] Code refactoring: everything now happens inside a class instead of the main plugin file<\/li>\n<li>[DEV] Allow changing the highlight color using the <code>nakedcatplugins_lang_attr_highlight_color<\/code> filter<\/li>\n<li>[TWEAK] Better information and screenshot about the highlighting feature for website Administrators and Editors, in the readme.txt file<\/li>\n<li>[TWEAK] Make evident that the language shown as a placeholder is the default website language when a custom language is not set for a block<\/li>\n<\/ul>\n\n<h4>1.2 - 2025-07-25<\/h4>\n\n<ul>\n<li>[NEW] Show visual outline around blocks that have a language attribute set - For easy identification, only for Administrators and Editors, and if enabled in Settings &gt; Writing<\/li>\n<\/ul>\n\n<h4>1.1<\/h4>\n\n<ul>\n<li>[NEW] Add support for the Cover block<\/li>\n<li>[DEV] Patchstack mVDP disclaimer on the readme file<\/li>\n<\/ul>\n\n<h4>1.0<\/h4>\n\n<ul>\n<li>First release<\/li>\n<\/ul>","raw_excerpt":"Add lang and dir attributes to Group, Columns, Cover, and other specific WordPress Blocks, or to the whole page\/post.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/238574","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=238574"}],"author":[{"embeddable":true,"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/nakedcatplugins"}],"wp:attachment":[{"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=238574"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=238574"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=238574"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=238574"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=238574"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=238574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}