Multilingual support for collections


#1

Hi ghost comunity,

I was trying to setup a multilingual blog but discovered the absence of some (easy) core functionalities. Imagine the following scenario:

I have a lot of English readers as well as some others from Germany, which are not so good with English. I would like to have my theme translated based on the collection I’m in. I’ve done the separation of posts in different languages like described here:
https://docs.ghost.org/tutorials/multi-language-content/

I tought about this problem and how to make the “/de” version of the site in German, as well as all posts in there. I came up with a simple solution and already build a fork for it.

In implemented a simple solution that oney includes changing the routes.yaml and adding an optional line for “language”:

collections:
/:
permalink: /{slug}/
filter: ‘tag:-hash-de’
/de/:
permalink: /de/{slug}/
filter: ‘tag:hash-de’
language: ‘de’

This works all the way down to the i18n translation, so templates are already supplied with the right language. It’s similar to changing the whole page default language, but just for a specific collection.