The answer
window.disqus_config = function() {
this.language = '{{ .Lang }}';
}
Why use window.disqus_config
?
According to the Disqus’ help page, we can override the language by adding this.
var disqus_config = function () {
this.language = "ja";
};
So basically the following JavaScript works.
var disqus_config = function () {
this.language = '{{ .Lang }}';
};
However, the variable disqus_config
doesn’t work with --minify
option because Hugo changes the name.
To solve it, you can use a window
object instead.
var disqus_config = function () {
window.disqus_config = '{{ .Lang }}';
};
Reference:
By the way…
Hugo has a Disqus template, and it was using var disqus_config
so I sent a pull request.
I was happy because it’s my first contribution to OSS.