hugo-toha/layouts/partials/helpers/country-code.html
Emruz Hossain 16f64aa4c2
Allow overwriting country flag for a language (#316)
Signed-off-by: hossainemruz <hossainemruz@gmail.com>
2021-05-17 17:43:06 +00:00

23 lines
759 B
HTML

{{ $languageCode:= .Lang }}
{{/* by default the language code and the country code are same */}}
{{ $countryCode:= $languageCode }}
{{/* language code and country code are not same for some countries. 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 }}
{{/* if the user specify a country code for a language via "params.flagOverwrites" field, then use it. */}}
{{ range site.Params.flagOverwrites }}
{{ if eq $languageCode .languageCode }}
{{ $countryCode = .countryCode }}
{{ end }}
{{ end }}
{{/* return the country code */}}
{{ return $countryCode }}