11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
16.55k stars 477 forks source link

generate automatic collection for website for each locale #3049

Open Dexus opened 9 months ago

Dexus commented 9 months ago

Is your feature request related to a problem? Please describe.

I need to create for each locale an own collection, but it would be cool, to have for each collection, that is automatic generated or created, it would also create a seperate one for each locale.

Describe the solution you'd like

automatic create a collection that is defined for each locale

Describe alternatives you've considered

No response

Additional context

No response

pdehaan commented 9 months ago

I think it mostly depends on how your locales/pages are set up. If its "About" pages, you could always just do something like tags: ["fr"] in your front matter to add localized pages to auto add them to a locale collection. Or if you have a lot of pages nested in a directory, you could do something like a directory data file, like "/it/it.11tydata.json" which adds all nested pages to an "it" collection:

{
  "tags": ["it"]
}

Or, depending on how your site is organized, you could always do something like .addCollection("de", collectionApi => {...}) in your eleventy.config.js file to manually create the locale collections based on some other criteria.

Dexus commented 9 months ago

I simply use the 2.0.1 lang tag in the parent folder to set the locale. But then the stipid is also that the categories/tags are not in the lists...

in the past wit 1.x i had created a list of locals that are supported, created each with .addCollection but now with the local support to create mulit-linguale websites, I think it would nice to have this created for the locals also automated.