{{/* Return a slice of language codes for all locales as expected by Google Translate. Google Translate (GT) seems particular about language tags. For zh it needs to be the full tag, including the region code: zh-cn. But for other languages, GT seems to want only the primary subtag. References: - https://gohugo.io/configuration/languages/ - https://datatracker.ietf.org/doc/html/rfc5646 */ -}} {{ $locales := slice -}} {{ range hugo.Sites -}} {{ $langCode := .Language.Locale -}} {{ $primaryTag := index (split $langCode "-") 0 -}} {{ $localeTagForGT := cond (eq .Language.Name "zh") $langCode $primaryTag -}} {{ $locales = $locales | append $localeTagForGT -}} {{ end -}} {{ return $locales -}}