{"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-10-02T13:45:09","modified_gmt":"2026-10-02T13:45:09","slug":"lang-attribute-blocks","status":"publish","type":"plugin","link":"https:\/\/pcd.wordpress.org\/plugins\/lang-attribute-blocks\/","author":23274606,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"3.3","stable_tag":"3.3","tested":"7.1.2","requires":"6.6","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-10-02 13:45:09","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"https:\/\/wordpress.org\/plugins\/lang-attribute-blocks\/","header_author_uri":"https:\/\/nakedcatplugins.com","rating":5,"author_block_rating":0,"active_installs":20,"downloads":1244,"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","revision":3319921},"1.1":{"tag":"1.1","author":"nakedcatplugins","date":"2025-06-30 11:16:34","revision":3319921},"1.2":{"tag":"1.2","author":"nakedcatplugins","date":"2025-07-25 10:57:49","revision":3334114},"2.0":{"tag":"2.0","author":"nakedcatplugins","date":"2025-08-01 16:36:18","revision":3337933},"2.1":{"tag":"2.1","author":"nakedcatplugins","date":"2025-08-09 13:38:09","revision":3342032},"2.2":{"tag":"2.2","author":"nakedcatplugins","date":"2025-10-20 16:54:32","revision":3381456},"3.0":{"tag":"3.0","author":"nakedcatplugins","date":"2026-03-09 12:13:50","revision":3478054},"3.1":{"tag":"3.1","author":"nakedcatplugins","date":"2026-06-04 14:12:06","revision":3561106},"3.2":{"tag":"3.2","author":"nakedcatplugins","date":"2026-10-02 13:43:28","revision":3724891},"3.3":{"tag":"3.3","author":"nakedcatplugins","date":"2026-10-02 13:45:09","revision":3724893}},"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":"","width":1544,"height":500},"banner-772x250.jpg":{"filename":"banner-772x250.jpg","revision":3381444,"resolution":"772x250","location":"assets","locale":"","width":772,"height":250}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0","1.1","1.2","2.0","2.1","2.2","3.0","3.1","3.2","3.3"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":3381444,"resolution":"1","location":"assets","locale":"","width":2486,"height":1466},"screenshot-2.png":{"filename":"screenshot-2.png","revision":3381444,"resolution":"2","location":"assets","locale":"","width":2488,"height":1228},"screenshot-3.png":{"filename":"screenshot-3.png","revision":3381444,"resolution":"3","location":"assets","locale":"","width":3064,"height":1622},"screenshot-4.png":{"filename":"screenshot-4.png","revision":3724893,"resolution":"4","location":"assets","locale":"","width":1512,"height":812},"screenshot-5.png":{"filename":"screenshot-5.png","revision":3724893,"resolution":"5","location":"assets","locale":"","width":1400,"height":861}},"screenshots":{"1":"Using the block editor to add a language attribute to a Group block","2":"The <code>lang<\/code> and <code>dir<\/code> attributes rendered on the frontend","3":"Using the highlighting option during the editing process","4":"The Language column on the Pages list, and setting a page\u2019s language with Quick Edit","5":"Setting the language of several pages at once with Bulk Edit"}},"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 <code>dir<\/code> 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"},{"src":"https:\/\/ps.w.org\/lang-attribute-blocks\/assets\/screenshot-4.png?rev=3724893","caption":"The Language column on the Pages list, and setting a page\u2019s language with Quick Edit"},{"src":"https:\/\/ps.w.org\/lang-attribute-blocks\/assets\/screenshot-5.png?rev=3724893","caption":"Setting the language of several pages at once with Bulk Edit"}],"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 the 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.\nFor even broader coverage, the plugin supports setting the language at the template level in the Site Editor (Appearance \u2192 Editor \u2192 Templates). A language set on a template is automatically applied to all pages and posts using that template, unless a specific language is set at the individual post or page level \u2014 in which case the post-level setting takes precedence.\nThis 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 template-level setting when all posts or pages sharing a template are in the same language, or the page-level setting when an entire page or post is written in a language other than the website or template 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 at the <strong>template level<\/strong> in the Site Editor: a \"Template Language\" panel lets you define the default language for all pages and posts using that template, which is automatically applied unless overridden at the individual post or page level<\/li>\n<li>Set the language and text direction for an <strong>individual page or post<\/strong>, both on the blocks and classic editor: a \"Page Language\" panel in the Document Settings sidebar overrides the HTML <code>lang<\/code> and <code>dir<\/code> attributes for that specific page, taking precedence over any template-level setting<\/li>\n<li>See the language set on each page or post in a <strong>Language column<\/strong> on the Pages and Posts lists, and change it with <strong>Quick Edit<\/strong>, or for many items at once with <strong>Bulk Edit<\/strong><\/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 all pages and posts using a given template: go to Appearance \u2192 Editor \u2192 Templates, open the desired template, and use the \"Template Language\" panel in the template settings sidebar.<\/li>\n<li>To set the language for an individual page or post (overriding any template-level setting): open the Document Settings sidebar (the panel icon at the top right of the editor) and use the \"Page Language\" 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 \"Block Language\" 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%20template-level%2C%20page-level%2C%20or%20block-level%20language%20setting%3F\"><h3>When should I use the template-level, page-level, or block-level language setting?<\/h3><\/dt>\n<dd><p>Use the <strong>Template Language<\/strong> setting (in the Site Editor, under Appearance \u2192 Editor \u2192 Templates) when you have a group of pages or posts that all share the same language and use the same template \u2014 for example, a dedicated template for all your French-language posts. The language set on the template is automatically applied to every page or post using it, so you don't need to configure each one individually. It can always be overridden at the individual post or page level.<\/p>\n\n<p>Use the <strong>Page Language<\/strong> setting (in the Document Settings sidebar) when a specific page or post is written in a different language \u2014 either overriding the template-level setting or setting it independently when no template language is defined. This overrides the <code>lang<\/code> attribute on the HTML element itself, which corresponds to WCAG 3.1.1 (Language of Page).<\/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\/Naked-Cat-Plugins\/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.3 - 2026-10-02<\/h4>\n\n<ul>\n<li>[NEW] See each page\u2019s and post\u2019s language in a new Language column, and set or remove it from Quick Edit or for many items at once with Bulk Edit<\/li>\n<li>[NEW] Language codes are checked as you type: WordPress-style codes like pt_PT become pt-PT, and codes that are not valid show an error<\/li>\n<li>[TWEAK] Requires WordPress 6.6 or newer, as the page and template language panel does not work on older versions<\/li>\n<li>[FIX] On themes that add their own classes to the page\u2019s main HTML element, such as Flatsome, pages with their own language lost those classes, which could break the theme\u2019s layout<\/li>\n<li>[FIX] The block language was applied to an inner element, or not at all, on Navigation blocks and on Cover and Content blocks set to an HTML element other than the default, instead of the whole block<\/li>\n<li>[FIX] On right-to-left websites, pages and templates set to a left-to-right language kept the right-to-left text direction<\/li>\n<li>[FIX] The language settings in the block editor were always shown in English, even when a translation was available<\/li>\n<li>[FIX] The language field placeholder showed the editor\u2019s own profile language instead of the website\u2019s language when the two were different<\/li>\n<li>[DEV] No more WordPress notice in the block widgets editor and Customizer when debugging is on<\/li>\n<li>[DEV] Tested up to WordPress 7.1<\/li>\n<\/ul>\n\n<h4>3.2 - 2026-08-02<\/h4>\n\n<ul>\n<li>[FIX] Fatal error on WordPress 5.9-6.1 since the plugin relies on <code>WP_HTML_Tag_Processor<\/code>, only available from WordPress 6.2, bumped the declared minimum version to match<\/li>\n<\/ul>\n\n<h4>3.1 - 2026-06-04<\/h4>\n\n<ul>\n<li>[NEW] Add a template language option in the Site Editor templates, used as the default page\/post language when no page\/post language is set<\/li>\n<li>[FIX] Load editor styles with <code>enqueue_block_assets<\/code> to avoid iframe style warnings<\/li>\n<li>[DEV] Tested up to 7.1-alpha-62456<\/li>\n<\/ul>\n\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, Templates, or to specific Posts\/pages.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/238574","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=238574"}],"author":[{"embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/nakedcatplugins"}],"wp:attachment":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=238574"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=238574"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=238574"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=238574"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=238574"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=238574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}