ponchique / gatsby-netlify-cms-multilanguage

The example of easy multi-language implementation with Gatsby + Netlify CMS
MIT License
8 stars 5 forks source link

Mixture of dynamic and static content #1

Open wc-lei opened 4 years ago

wc-lei commented 4 years ago

Hi, Thanks for creating such an inspiring repository. I understand this works well with static contents such as markdown files. However, if I have dynamic pages/components, is it possible to use a plugin like i18n or gatsby-intl? These plugins create a semantic path which is in conflict with language selection logic, isn't it?

ponchique commented 4 years ago

Hi @wc-lei

Many thanks :)

Let me ask you one question so I can understand you better.

Does your project have exactly the same structure as https://github.com/wiziple/gatsby-plugin-intl/tree/master/examples/gatsby-starter-default-intl?

If no, can you send the example of the structure you have?

wc-lei commented 4 years ago

@ponchique No, my project structure is a default boilerplate created from NetlifyCMS with Gatsby. It has those About, Products templates and markdown files.

ponchique commented 4 years ago

All right, I got you.

So I just had a look at how the data is stored in the starter to get the gatsby-intl works and it looks pretty bulky as you store all the pages data in the same file, for example home and about you store in en.json and de.json. I'm actually not sure should they be stored in the same file or you can split them off.

However, if you fetch the data to the same folder from CMS it possibly means that all of the data will be mixed up, so that means the performance of your CMS, maintenance, and readability of the files could be poor.

But theoretically, if we take 2-3 pages, it's okay, it's possible, but what if we need 50 more pages? Or if we need to have 3x time more data on the pages? Or blog-posts which should be stored in different files?

However, just found a new configuration property locale in Netlify CMS, maybe it worth to look into it: https://www.netlifycms.org/docs/configuration-options/#locale

Let me know how you manage this

wc-lei commented 4 years ago

@ponchique Thanks for your comments. what I am thinking is a clear separation of static and dynamic contents. gatsby-plugin-intl and all the localized texts are only for dynamic pages (.js) created by developers. Static pages are managed in NetlifyCMS online editor by content managers, and I duplicated the collection for each language, just as you did. My project would not have many pages, so this should work in theory. What borders me is the intl plugin handles localized pages automatically as /locale/pageSlug, this works for dynamic pages since I only need one copy, but for static contents, I couldn't figure out how the page link should be with intl plugin in the middle.

ponchique commented 4 years ago

Okay, I got you, I think you have to ask guys who were working on gatsby-intl in that case.

Please, keep updated how you solved your issue 🙂