Eleventy: Internationalization Example using JS Data Files

Created on 20 Sep 2018  路  8Comments  路  Source: 11ty/eleventy

Most helpful comment

Just chiming in for Internationalization and the possibility to have a single collection with multiple languages.

While not being my preferred approach (separate collections for each lgg make more sense IMHO), you could do it by setting a locale key in your front matter for each item in your mixed lgg collection (I would also add a translationKey to create an explicit relation between all lgg versions of the same content items if you need a language switcher). That key can be set in each front matter or you can use directory data files.

As far as pagination go, you could use the new before pagination parameter to only get the data you want from that mixed languages collection.

I did a couple of multilingual websites with Eleventy using the following setup (separate collections for each language)

https://www.webstoemp.com/blog/multilingual-sites-eleventy/

All 8 comments

How to deal with collections for multiple languages? By creating as many collections as the number of languages available? For example collection "news": news_en, news_de, news_fr, etc?

It would be great if it would be possible to "pass" a language to a collection. Now you can loop over a collection and skip items that are not available at one language, but that would break pagination.

Perhaps there's an easy way - I haven't created a multilanguage site with Eleventy so far but this one comes to my mind as a problem.

Where is the internationalization example? I don't see it in the linked docs page, although I understand you're saying this can be done with a JS data file. If I wanted to use y18n, for example, is there any Eleventy-specific setup I would need to implement, aside from npm installing y18n and following their documentation?

This repository is now using lodash style issue management for documentation requests. This means documentation issues will now be closed instead of leaving them open.

View the documentation queue backlog here. Don鈥檛 forget to upvote the top comment with 馃憤!

@rolandtoth did you find a way to solve the multi-lang collections problem? I'm struggling with this as well 馃槬

No, I had no ML project so far. Probably I would add a frontmatter property to each page, but I haven't tried yet.

Just chiming in for Internationalization and the possibility to have a single collection with multiple languages.

While not being my preferred approach (separate collections for each lgg make more sense IMHO), you could do it by setting a locale key in your front matter for each item in your mixed lgg collection (I would also add a translationKey to create an explicit relation between all lgg versions of the same content items if you need a language switcher). That key can be set in each front matter or you can use directory data files.

As far as pagination go, you could use the new before pagination parameter to only get the data you want from that mixed languages collection.

I did a couple of multilingual websites with Eleventy using the following setup (separate collections for each language)

https://www.webstoemp.com/blog/multilingual-sites-eleventy/

Hi, I looking for this support also, becuase you should be able to cross link all languages of the same content. But with the currently support it's not possible to do somthing good with it.

@Dexus I suppose you are not talking about JS data files here but rather about items in various collections.

If that's the case, did you have a look at using a translation key in the front matters of your linguistic versions of the same content ? I've used it in several projects and it works well, provided that you can educate the client team if they are maintaining the site.

https://www.webstoemp.com/blog/language-switcher-multilingual-jamstack-sites/

Was this page helpful?
0 / 5 - 0 ratings