Include a different partial template based on language

Hi Guys,

I am trying to build multilingual website in English (default) and Russian. So far, I managed to translate a few posts by changing markdown name from Post.md to Post.ru.md. I want to do the same with the html parials on my home page. I have subheader.html in my partials which is in Englsh and it is included in the home page. I tried to add subheader.ru.html and hoped that it will show the russian template on the home page but it is obviously not working like that. I thought i could write a function to include the subheader partial based on the language but my knowledge is very limited… Here is my home page:

<div class="container">

        {{ if .Site.Params.showSubheader }}
            {{ partial "subheader.html" . }}
        {{ end }}

</div>

How can i include a check in the template so it shows the subheader.ru.html on the russian language? Or is there any simpler way to accomplish this? Thank you in advance!

There is no Template Lookout on partials, so I don’t think you can rely on that.

This is untested:

{{ if .Site.Params.showSubheader }}
            {{ partial (printf "subheader.%s.html" .Lang) . }}
{{ end }}