Multilingual only for data folder


#1

Hi, I’m trying to add a multilingual functionality to my website for French and Spanish (on top of English). However, I have 2 issues/questions:

  • How can I have the data folder to behave the same way as content by filename. I would like to have team.en.yml, team.fr.yml and team.es.yml but in the documentation, it only mentions the content folder.
  • In the content folder, I would like to show all blog posts irrelevant of the languages (at least for now, since I don’t have enough content for fr and es).

I’m basically only interested in translating the information part of the website (about us, services, team…) but not the blog part.
Thanks a lot for your help.


#2

The data folder is language agnostic, but you can do something ala:

{{ $mydata := (index .Site.Data .Site.Language.Lang) }}

The above would need a /data/fr, i.e. a folder per language.


#3

I’ve done it using a variation of what @bep suggest (in action here: https://moodlebox.net). See e.g. my carousel partial:


And the structure of the corresponding data folder:


#4

Thanks a lot, that was really helpful. I thought I made an error in the config files while I actually made a stupid error in the layout, I was putting {{ $mydata := (index .Site.Data .Site.Language.Lang) }} above and not below the safeHTML.