Adding multi-lingual comments to your website using Disqus

Khalid AlnajjarWeb Development, WordPress Leave a Comment

Having comments and discussions on your website is an important thing as it encourages your visitors to interact and share ideas, not to mention any SEO advantages. Disqus is a great platform for discussions and comments. With it, you can add commenting feature to your website without any backend development. All you need to do is create an account, link your website and include a Javascript snippet to your page, and you are done!

I have decided to start blogging in Arabic, and I wanted to load Disqus (the commenting section) in Arabic. Luckily, I am using a very customization theme, X Theme, which allows adding custom Javascript without touching any WordPress code.

In case you want to use Disqus in a multi-lingual website, add the following snippet to your page and Disqus will be loaded in the language of your site.

jQuery(function($){
	$(document).ready(function(){
		function setDisqusLanguage(lang){
			if(typeof DISQUS !== "undefined"){
				var disqus_ar = function() {this.language = lang; }
				DISQUS.reset({reload:true, config:disqus_ar});
			}
			else{
				setTimeout(setDisqusLanguage, 250);
			}
		}
		var _html_lang = $('html').attr('lang');
		if(_html_lang){
			setDisqusLanguage(_html_lang);
		}
	});
});

This is how easy you can add multi-lingual comments section to your website! I hope this was helpful 🙂

* (This post contains affiliate links. Please read my disclosures for more details).

Share this Post