{"id":4859,"date":"2024-12-12T11:26:11","date_gmt":"2024-12-12T05:56:11","guid":{"rendered":"https:\/\/holithemes.com\/plugins\/click-to-chat\/?p=4859"},"modified":"2025-05-16T10:34:08","modified_gmt":"2025-05-16T05:04:08","slug":"how-to-display-click-to-chat-widget-based-on-user-language","status":"publish","type":"post","link":"https:\/\/holithemes.com\/plugins\/click-to-chat\/how-to-display-click-to-chat-widget-based-on-user-language\/","title":{"rendered":"How to display Click to Chat widget based on user Language"},"content":{"rendered":"\n<p>We can customize the visibility of certain content on your website depending on the user&#8217;s language settings. This is useful when you want to display different elements based on the language the user\u2019s browser is set to.<\/p>\n\n\n\n<p>Here\u2019s how you can achieve this using CSS:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<p>When we want to show or hide a specific element, such as a chat widget, based on the user&#8217;s language, the <code>lang<\/code> attribute in the&nbsp;<code>&lt;html&gt;<\/code>&nbsp;tag can serve as a reliable indicator of the user&#8217;s language preferences. This attribute enables us to apply conditional CSS rules tailored to different languages effectively.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\" style=\"margin-top:0;margin-bottom:0\"><code>\/* Hide the chat widget for specific languages *\/<br>html[lang=\"en-US\"] .ht-ctc-chat,  \/* English (US) *\/<br>html[lang=\"es-ES\"] .ht-ctc-chat,  \/* Spanish (Spain) *\/<br>html[lang=\"sv-SE\"] .ht-ctc-chat,  \/* Swedish (Sweden) *\/<br>html[lang=\"pl-PL\"] .ht-ctc-chat { \/* Polish (Poland) *\/<br>     display: none !important;   \/*not important*\/<br>}<br><\/code><\/pre>\n\n\n\n<p><strong>In this example:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The chat widget (<code>.ht-ctc-chat<\/code>) will be hidden when the user&#8217;s browser language is set to English (US), Spanish (Spain), Swedish (Sweden), or Polish (Poland).<\/li>\n\n\n\n<li>You can change the <code>lang<\/code> attribute values to target other languages as well.<\/li>\n<\/ul>\n\n\n\n<p>If you want to show or hide other elements for different languages, just update the <code>html[lang=\"...\"]<\/code> value with the appropriate language code and target the desired element.<\/p>\n\n\n\n<p>For instance, to hide a click-to-chat widget only on French pages, you could use:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\/* hide the English message only for users with a en-US language setting *\/<br>html[lang=\"en-US\"] .<code>ht-ctc-chat<\/code> {<br>    display: block;<br>}<br><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can check the language from the browser itself. By inspecting (F12) the code from inspect browser tools.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" width=\"614\" height=\"142\" src=\"https:\/\/holithemes.com\/plugins\/click-to-chat\/wp-content\/uploads\/2024\/12\/Based-on-language-inspect-image.webp\" alt=\"\" class=\"wp-image-4868\" style=\"width:736px;height:auto\" srcset=\"https:\/\/holithemes.com\/plugins\/click-to-chat\/wp-content\/uploads\/2024\/12\/Based-on-language-inspect-image.webp 614w, https:\/\/holithemes.com\/plugins\/click-to-chat\/wp-content\/uploads\/2024\/12\/Based-on-language-inspect-image-300x69.webp 300w\" sizes=\"(max-width: 614px) 100vw, 614px\" \/><\/figure>\n\n\n\n<p>By using this method, you can manage language-specific content efficiently.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Explore More Display Options<\/h4>\n\n\n\n<p><a href=\"https:\/\/holithemes.com\/plugins\/click-to-chat\/display-based-on-country\/\">Display based on Country<br><\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/holithemes.com\/plugins\/click-to-chat\/display-based-on-user-login-status\/\">Display based on Website Visitor Login Status<\/a><\/p>\n\n\n\n<p><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We can customize the visibility of certain content on your website depending on the user&#8217;s language settings. This is useful when you want to display different elements based on the language the user\u2019s browser is set to. Here\u2019s how you can achieve this using CSS: Example When we want to show or hide a specific [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":"","_htd2_assets":[]},"categories":[63],"tags":[],"class_list":["post-4859","post","type-post","status-publish","format-standard","hentry","category-display-settings"],"_links":{"self":[{"href":"https:\/\/holithemes.com\/plugins\/click-to-chat\/wp-json\/wp\/v2\/posts\/4859","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/holithemes.com\/plugins\/click-to-chat\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/holithemes.com\/plugins\/click-to-chat\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/holithemes.com\/plugins\/click-to-chat\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/holithemes.com\/plugins\/click-to-chat\/wp-json\/wp\/v2\/comments?post=4859"}],"version-history":[{"count":0,"href":"https:\/\/holithemes.com\/plugins\/click-to-chat\/wp-json\/wp\/v2\/posts\/4859\/revisions"}],"wp:attachment":[{"href":"https:\/\/holithemes.com\/plugins\/click-to-chat\/wp-json\/wp\/v2\/media?parent=4859"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/holithemes.com\/plugins\/click-to-chat\/wp-json\/wp\/v2\/categories?post=4859"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/holithemes.com\/plugins\/click-to-chat\/wp-json\/wp\/v2\/tags?post=4859"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}