Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localising the default layout #81

Closed
BeMrTeal opened this issue Oct 25, 2017 · 5 comments
Closed

Localising the default layout #81

BeMrTeal opened this issue Oct 25, 2017 · 5 comments

Comments

@BeMrTeal
Copy link

BeMrTeal commented Oct 25, 2017

This is more a question than an issue.

How would I localise the default layout in order to have my includes in different languages?

I managed to get my menu to dynamically sort the language with this liquid code:

{% assign pages_list = site.pages | sort: 'index' %}
          {% assign written = "" | split: '' %}
          {% for node in pages_list %}
            {% if written contains node.title %}
              {% continue %}
            {% endif %}
            {% if node.title != null %}
              {% if node.layout == "page" and node.lang == site.active_lang %}
          <li class="nav-item mx-3">
            <a class="nav-link header--nav__link {% if page.url == node.url %} active {% endif %}" href="{{site.baseurl}}{{ node.url }}">{{ node.title }}</a>
          </li>
              {% endif %}
              {% assign written = written | push: node.title %}
            {% endif %}
          {% endfor %}

but I wasn't able to get my default layout to pick the includes accordingly to the site.active_language any suggestion?

Cheers

@BeMrTeal
Copy link
Author

I see that in the LogRhythm website you have subdomains for languages but how do you build the home pages in different languages?
Do you have a different layout for each language?
How did you set it so you can have Jekyll to build it?

I'd love to have a tip on how to do that for my site.

@untra
Copy link
Owner

untra commented Oct 30, 2017

Hey @BernardoMed,

So I cannot tell you how the Logrhythm website does it's full layout. In fact they made recent changes that I was not involved in. I'm not sure how they recently setup the language subdomains, so I cannot help you with that.

I can tell you how the example polyglot website works. In fact, it's source code is included on this repo.

how do you build the home pages in different languages?

You are going to want to make multiple index.md pages for each of your languages (index.es.md, index.en.md, ...) In the headers, set the correct lang for each page. I would guess that is the secret sauce to what you're missing.

Cheers,
@untra

@BeMrTeal
Copy link
Author

Thanks mate, I'll give it a try.

bitmoji

@BeMrTeal
Copy link
Author

BeMrTeal commented Nov 1, 2017

Right @untra,

I have one index.md for each language (index.es.md, index.en.md, index.pt.md), one layout > home.html for each language (home-en.html ... ) and one layout > default.html for each language (default-en.html ...)

I also have one of each _includes file for each language.

I discovered that if I change the language and layout of the index.md file, it changes the layout to the required language so the million dollars question is: What do I have to do in order to get the correct index.md file to be loaded when the corresponded language is selected by the user?

Once again, thanks for your help.

bitmoji

@BeMrTeal
Copy link
Author

BeMrTeal commented Nov 1, 2017

I just realised that the index page any language is compiled with the default language so this is clearly me not knowing how to setup correctly the languages in the _config.yml file.

bitmoji

@BeMrTeal BeMrTeal closed this as completed Nov 1, 2017
@BeMrTeal BeMrTeal reopened this Nov 2, 2017
@untra untra closed this as completed Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants