hugo-toha/layouts/partials/helpers/country-code.html
2021-05-10 10:52:15 +02:00

19 lines
710 B
HTML

{{/* if there is no custom flag provided, we define the flag with the country code */}}
{{ $languageCode:= .Lang }}
{{ $countryCode:= $languageCode }}
{{/* if the user has selected a custom flag, display it */}}
{{ if isset .Site.Params "flag" }}
{{ $countryCode = .Param "flag" }}
{{ else }}
{{/* but some language codes dont have an equivalent country code. we need to fix them. */}}
{{ if eq $languageCode "en" }}
{{ $countryCode = "gb" }}
{{ else if eq $languageCode "bn" }}
{{ $countryCode = "bd" }}
{{ else if eq $languageCode "hi" }}
{{ $countryCode = "in" }}
{{ end }}
{{ end }}
{{/* return the country code */}}
{{ return $countryCode }}