Open hankhero opened 4 years ago
Hey @hankhero, thanks for taking the time to write this up. Definitely think that enabling plugin users the ability to work from PO files is a great idea.
Perhaps this could be a helper function exported from the plugin? I'll take some time to explore this too, and we'll see where we can get it to.
I've not had time to dig back into this, but have spotted https://github.com/sgissinger/eleventy-plugin-i18n-gettext/, which might offer more of what you're after 🙂
I am setting up a site with this way, however I wanted to make sure to use a file format for translations that can be sent to translators, or used with standard translation tools. Found out that .po file seems common, also it is an easy text format. So: I have an example, basic code. Wonder if it should be cleaned up and added to the project, or maybe be an example? It introduces one dependency on a po file parser.
This is how it works:
Mty sample now have english and spanish. I make two .po files (en.po and es.po), add in a folder somewhere, in my case src/developer/_translations (src/developer is my input directory). This is how the spanish .po file looks like (es.po):
Added dependency:
npm install gettext-parser --save-dev
And in .eleventy.js this is added. Yes can be cleaned up. And could potentially be a made into a patch, but first I want to hear what you think....