assemble/grunt-assemble-i18n

Add documentation

rauberdaniel opened this issue · 30 comments

Please add some basic documentation about how to install and use this plugin.

ain commented

👍

Valid request, I was already thinking of doing it (as we're using it in
production). Will definitely happen soon :)

@ain if you're going to add some documentation, take a look at verb and grunt-verb

Hello,

Thanks for your work. Any news about some basic documentation?

ain commented

Yes, I've just today, on our performance intensive compilation, added options for unikeys and gc which helped me to cut memory consumption by 6x. I'll push a PR at the earliest possibility and once PRs get merged, also add the docu.

Thank you. My project main feature is based on i18n support and content translation. So I chose Assemble and the i18n middleware which should be a good fit :)

ain commented

Yes. That's exactly the nature of our project too, as you can see at
http://sennheiser-momentum.com ;)

Any updates on this, or alternatively can someone point me to an example project?

Thanks!

Really sorry about that. We rely on it heavily so I should be doing the documentation but I am crazy busy

Here's where we use it.

https://github.com/wet-boew/wet-boew/blob/master/Gruntfile.coffee#L401-L413

Note that the list of languages comes from another task that takes a csv and creates the JSON files.

+1 for having a little documentation for this. Starred and watched this useful project.

Great. What's the status? I have no idea how this works, would love an example at least... :-)

I should get on it but I can help you with your use case in the meantime

Thanks. I want to add a module for a specific language, so I would like to check if a translation is defined, and if it was, I would render the module. How can I make that check?

The way this works, you have to specify in the Gruntfile which languages your support. You can do that by specifying it manually or by using grunt file matching to list he languages you have. Do you have a repo I can look at?

Btw, here's one of our tasks for this middleware. We use a list of langauge from a task that splits a csv file to seperate .json file for each language

https://github.com/wet-boew/wet-boew/blob/master/Gruntfile.coffee#L461-L473

Thanks. That wasn't exact what I was looking for tho. I use your test-example from Github, and uses the permalink-version.

What I would like, is that if the description in fr.json wan't entered, then the description block shouldn't be rendered. This way I can have the languages controlling what elements there is on the page. For example, in Denmark there is a strict cookie law, which means that each page has to have a overlay of some kind that explains how you use cookies. But on most other languages, that's not required.

Somthing like:

{{i18n exist="description"}}
{{i18n "description}}
{{/i18n}}

Can that be achievable?

That use case is not supported at least not in this syntax...let me think about this one

Have you had any chance to look at it?

Is that the only difference you need? Would you still have one template driving the generation of pages in multiple languages?

Yes. Why? Do you think that's a poor approach?

No no, I don't think it should be too hard. I should have something tomorrow

Hi again. How's it going?
I was wondering another thing as well. Is it possible to support Pages Collections, with different layouts?
http://assemble.io/docs/Pages-Collections.html

ain commented

@BlueBlau layouts aren't the scope of i18n, but yes you can.

@ain Great. How would I achieve this? I'm used to do this in regular Assemble, but I failed to figure out how to do it with i18n.

How can I achieve this?

@LaurentGoderre Have you had a chance to look at this?
@ain Do you have a solution/approach I can try out?

Perhaps it's not the most elegant solution but this works

---
title: Home
heading: 'Yo, Assemble!'
lead: Welcome to my blog!
warning: '<%= i18n[language].warning %>'
---
<div class="jumbotron">
  <h1>{{ heading }}</h1>
  {{#if warning}}<p>{{warning}}</p>{{/if}}
  <p>{{{i18n "paragraph"}}}</p>
</div>

Here's the repo that I promised (sorry for the delay)

https://github.com/LaurentGoderre/i18n-demo

@LaurentGoderre Thanks for the demo is very clear. but you can use Markdown instead of YML?

I believe you can. BTW, both are not mutually exclusive, the code between --- is what is called front matter and can be used on Handlebars or Markdown files and can either be in YAML or JSON syntax

Documentation coming any time soon?