jekyll-theme-hpstr icon indicating copy to clipboard operation
jekyll-theme-hpstr copied to clipboard

Multilingual support

Open avarabyeu opened this issue 9 years ago • 2 comments

First of all, thanks for such a great theme! Is it possible to add localization support?

avarabyeu avatar May 24 '16 15:05 avarabyeu

Sure. I probably won't have the time to do it since I'm not actively adding new features for this theme. But if you wanted to submit a PR I'd look at it.

I've tackled this in my other themes so I'd be looking for something similar if I was to merge it in.

Anything beyond localizing simple text strings pushes things into plugin territory and I'd like to avoid that since it's best left for the user to decide if they want to add it.

mmistakes avatar May 25 '16 12:05 mmistakes

Hi, If you want, I already implement a kind of multilingual feature on my own blog. My blog is still in French, but I add the ability of adding post in English.

  1. First, I've created a lang attribute on my post's mardown files.

    layout: post
    title: my title
    description: "en"
    tags: ["a", "b", "c"]
    lang: en
    image:
    
  2. Then, when I loop on articles, I check if lang is defined to put a flag.
    Look: (template file)

    {% for post in site.posts %}
    //...
        {% if post.lang == "en" %}
            <li class="entry-title">
                <a href="{{ site.url }}{{ post.url }}" title="{{ post.title }}"><img src="{{ site.url }}/images/uk-flag.png" alt="english article"> {{ post.title }}</a>
            </li>
        {% else %}
            <li class="entry-title">
                <a href="{{ site.url }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a>
            </li>
        {% endif %}
    //...
    {% endfor %}
    

Here's the result: http://maxpou.fr (look line: "Vagrant, Symfony and Windows are not incompatibles")

maxpou avatar May 26 '16 08:05 maxpou