So what I’m doing is I have a theme that will have a data/lang
folder with a bunch of files, like en.yml
and lt.yml
or whatever.
In these files, you can access language strings for the theme like this: .Site.Data.lang.en.okStatus
. Here’s the problem: I can’t hardcode a language in the theme, I want it to be changeable from the config.yml file. As such, I’ve got a .Site.LanguageCode
variable that would change whether it would be lt
, or en
, or en-CA
, etc.
My code:
{{ $path := .Site.LanguageCode | printf "%s.%s" ".Site.Data.lang" | printf "%s" }}
{{ $path }}
returns .Site.Data.lang.en
.
I expect: map[downStatus:Experiencing major issues disruptedStatus:Experiencing disruptions noticeStatus:Please read announcement okStatus:All systems operationalx]
.
Also, I took a look at this, which kinda helped, but not really? String / Variable Concatenation to build Path for partial It’s kinda similar.