modiimedia / contentful-hugo

A CLI tool that pulls data from Contentful and turns it into markdown files for Hugo and other static site generators. It also includes an express server that can be used for local development and content previews

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for localised fields

initrode opened this issue · comments

Hey there,

I couldn't see any support for retrieving any field localisations from Contentful and writing the entire content to a separate lang folder. The basic lang stuff is fine but it gets messy in terms of configuration files with locale filters for every type. It would be much cleaner to segregate languages at the domain level and do cross linking (As presumably they would have the same sys.id) ?

-- en
       | - articles
-- fr-fr
       | - articles
-- de-de
       | - articles

etc...

It's probably a reasonable assumption to make that if you are working with locales in Contentful you want them all in the response by default so it could resolve the folders to the Contentful locale name but you could add a map to override them if needed?

You could also add overrides at a field level which would prevent localisations from being returned entirely (doNotRetrieveLocales: {true | false}) ?

Yea I agree that proper localization support would be killer. There's an open issue for it here.

Currently the only work around is using the filters parameter but as you mentioned that get's messy pretty quick.

I don't know how I feel about retrieving locales by default I think I would prefer to have them explicitly specified in the config (probably as a global setting to prevent duplication)

something like:

module.exports = {
   locales: ["en", "fr"],
   singleTypes: [],
   repeatableTypes: []
}

and then we could set retrieveLocales to false on specific contentTypes that we want to ignore locales for (assuming it's set to true by default).

I haven't decided yet if handling translations by filename or doing by directory would be better.

I'll go ahead and close this issue since it's a duplicate of #2. We can continue discussion there.