11ty / eleventy

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

plugin: i18n #420

Closed DirtyF closed 5 years ago

DirtyF commented 5 years ago

11ty-plugin-i18n helps with content localization:

๐Ÿ‡ฌ๐Ÿ‡ง ๐Ÿ‡ช๐Ÿ‡ธ ๐Ÿ‡จ๐Ÿ‡ณ ๐Ÿ‡ซ๐Ÿ‡ท ๐Ÿ‡ฏ๐Ÿ‡ต ๐Ÿ‡ฉ๐Ÿ‡ช ๐Ÿ‡ง๐Ÿ‡ท ๐Ÿ‡ท๐Ÿ‡บ ๐Ÿ‡ต๐Ÿ‡ฑ ๐Ÿ‡ฆ๐Ÿ‡ท ๐Ÿ‡ฎ๐Ÿ‡ท ๐Ÿ‡น๐Ÿ‡ท

chrisdmacrae commented 5 years ago

@dirtyf can you point me at the "best" or most widely adopted i18n implementation for Jekyll?

DirtyF commented 5 years ago

I don't know about the most widely adopted, but I know about the latest attempt is to handle locales: https://github.com/ashmaroli/jekyll-locale.

Ryuno-Ki commented 5 years ago

For a project I've used jekyll-multiple-languages-plugin, but it caused some issues with SEO topics. Namely sitemaps and alternate links.

Ryuno-Ki commented 5 years ago

Just ran into https://www.webstoemp.com/blog/multilingual-sites-eleventy/ today.

reubenlillie commented 5 years ago

Iโ€™ve been playing around with the suggestions in the link @Ryuno-Ki shared. And, at least as of this post, I have three concerns.

  1. Perhaps because this solution is not in the official docs (yet?), it feels like a hack rather than a bona fide integration. If this is, in fact, a preferable solution, then when we put it in the docs, it should include examples in other template languages (JS specifically), not only nunjucks.
  2. There does not appear to be a way, with this approach, to associate language-specific endpoints with each other in the directory structure (cf. Hugo example).
  3. On a related note, is this solution compatible with CMSs (e.g., Netlfiy CMS) or translation software like OmegaT or Pontoon?
jeromecoupe commented 5 years ago

Hey there. I wrote this post so please allow me to respond here.

  1. Not a hack IMHO. It only uses core Eleventy functionalities, mainly directory data files (so you donโ€™t have to put the lgg specific info in each front-matter) and global data files (for string translations). The rest is just using the API for collections. That approach can easily work with other templating lgg (liquid or js) since it is only using simple loops to display data.
  2. Both the Hugo articles you reference are just content and string translations using dictionnaries, which are covered in the post. If what you want is a per content item lgg switcher (get other lgg versions from a single item), the easiest approach is probably to rely on a key/value pair in front matter to give you something to work with. This is a standard approach with SSG. Documented here for Jekyll for example (transposable to 11ty) https://forestry.io/blog/creating-a-multilingual-blog-with-jekyll/ You can then query for that key / value pair in your templates, either using custom multilingual collections or by using the โ€˜getAll()ยด method of the collection API to build a single collection of all your items
  3. Yes, since the solution relies entirely on collections and data files, you can configure Netlify CMS, Forestry, etc to work with that, no problem.

Sorry I am on a phone so no code samples, but Iโ€™ll try to write a post about lgg switcher whenever I get some time.

For me, there is a big difference in philosophy between Hugo and 11ty.

Neither approach is right or wrong, they both have their advantages and drawbacks. What you go with depends on the project at hand, as always.

reubenlillie commented 5 years ago

@jeromecoupe, of course. I don't really believe your solution is a hack. It's actually rather elegant. Sorry if I contributed any confusion or hard feelings. I was more addressing how it might feel that way to folks (particularly clients) who want i18n in the official docs and who may be looking for a way of associating translation files. Also, I respect the differences between 11ty and other SSGs, and I cherish 11ty's flexibility. By sharing examples from other SSGs, I'm just looking for inspiration by way of comparison. I fully expect 11ty's preferred i18n solution to be better than the competition.

jeromecoupe commented 5 years ago

@reubenlillie No hard feelings at all, man. Just wanted to clarify / expand on the blogpost.

As for clients, this is not usually a problem for me. They would very rarely look at docs and most of them only see an admin like Netlify CMS, Forestry, Strapi, Dato etc.

Very rarely does one of my client care about the fact that their data is in markdown or in a DB somewhere. The ones that do generally like markdown and are technical enough to manage multilingual collections or data files as long as the basic infrastructure is built. One of them even uses Github as a CMS ;o)

reubenlillie commented 5 years ago

Sure, some of my clients are devs whom I'm trying to reassure they truly want JAMstack solutions. (Like migrating from WordPress, in which case I have to sell i18n as you've presented it over WPML or something.)

jeromecoupe commented 5 years ago

To be honest I have vowed never to do a WP project ever again. Using Craft for such projects

reubenlillie commented 5 years ago

Iโ€™m in the process of converting a lot of old WP projects with clients now. The i18n issues Iโ€™ve mentioned are among the primary sticking points.

Ryuno-Ki commented 5 years ago

@jeromecoupe Hey, thanks for chiming in here!

Sorry for not having you tagged in https://github.com/11ty/eleventy/issues/420#issuecomment-500123096.

Would you mind to link from your blog to here in case people are looking for an official way?

Ryuno-Ki commented 5 years ago

@reubenlillie Could you add a comment in #488?

I was wondering about starting an importer repo somewhen soon (using my Jekyll blog + my old WordPress.com blogs as starting points).

Will drop a link to the repo in that other ticket. Feedback welcome.

reubenlillie commented 5 years ago

@Ryuno-Ki, I could add a comment to the other issue thread, but I'm not sure what you'd like me to say.

zachleat commented 5 years ago

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

View the enhancement backlog here. Donโ€™t forget to upvote the top comment with ๐Ÿ‘!

Snugug commented 5 years ago

Can this get reopened?

DirtyF commented 5 years ago

@Snugug It's how this repo works: Closed by default, vote for the feature, and hope that it will get some attention from the community.

sirinath commented 4 years ago

Following metadata might be good to have in the font matters:

Also, tag/taxonomy management will be crucial as the translation will have to display the appropriate tags/taxonomies for the post. Therefore there should be a way to add to the site data:

Similarly, all collections and each item in the font matter will need to have a translated mapping, but not essential as this is not part of the user-facing part. If it is not translation there will need to be a way to inherit font matter content so there is a single point of truth. This might open possibilities of duplication and omission also.

E.g.

images:
  - ???.jpg
  - โ€ฆ.jpg
  - parrot.gif

will become

เถปเท–เถด:
  - ???.jpg
  - โ€ฆ.jpg
  - parrot.gif

In the Sinhala traslation.

So en-uk:images will need mapping si:เถปเท–เถด. So in pagination and other places if there is images it should become เถปเท–เถด when looking through the collections in the Sinhala template.

sirinath commented 4 years ago

How Middleman handles localization (i18n) seams interesting.

adamduncan commented 4 years ago

Hey all, we're putting together a multilingual Eleventy site at the moment, and also found ourselves needing some translation support. Having been motivated by some of the articles here, we've come up with: https://github.com/adamduncan/eleventy-plugin-i18n

Hope it comes in handy. Would love to hear any feedback you have ๐Ÿš€

zachleat commented 2 years ago

Docs page: https://www.11ty.dev/docs/i18n/ Plugin page: https://www.11ty.dev/docs/plugins/i18n/ (2.0.0-canary.13)

I donโ€™t think Eleventy will take an opinionated stance on a library to localize strings but we do link to a few options on those pages!