octopress / multilingual

Write elegant multi-language Jekyll sites
MIT License
69 stars 15 forks source link

Can't filter Pages by language #19

Open uaqben opened 9 years ago

uaqben commented 9 years ago

I've tried quite a few approaches, but I just can't figure this thing out.

Posts for me work fine.

But I can't figure a way to scope only the current language's Pages that I want displayed in the site's navigation bar.

Any pointers/suggestions?

I take it the following is not implemented, correct?

{% for page in site.pages_by_language.en %}

I've tried using set_lang, but didn't work either, I get an error from Jekyll/Liquid

 {% set_lang en %}
 {% for page in site.pages %}
 {% if page.title %}
     <li class="page-scroll">
         <a href="{{ lang }}{{ site.baseurl }}{{ page.url }}">{{ page.title }}</a>
     </li>
 {% endif %}
 {% endfor %}
 {% endset_lang %}

Liquid Exception: can't clone NilClass

imathis commented 9 years ago

You're correct there is no pages_by_language var. The reason I provide this feature for posts, is that it's a very common patter to have post indexes, rss feeds and archive pages which would all need to filter the post loop for different languages. In most cases it doesn't make sense to loop through all site pages. What is your use case for filtering a loop of all pages?

uaqben commented 9 years ago

Hi @imathis - just came back from 2 week break.

My use case is the following - I wish to use Octopress to host a "full" multilingual site, which will include a blog/news section, as well as "static/normal" pages. Therefore, not only do I wish to be able to translate the news/blog posts, but also every single page on the site, such as: Services or Products, About, Contact, etc.

BTW. I realized that my pull request was faulty - as I manually redid the changes from memory, and forgot to edit a line - I have just fixed that and, as per info I found on stackoverflow on how to modify a pull request, I will resubmit it. Pls excuse the hassle - on the other hand it is a good learning experience for me ;)