kurtsson / jekyll-multiple-languages-plugin

I18n support for Jekyll and Octopress
MIT License
922 stars 203 forks source link

permalinks and language switcher example are incompatible #76

Open jinnatar opened 7 years ago

jinnatar commented 7 years ago

As written the example language switcher doesn't work on pages that have a permalink, apparently regardless if there's a translated permalink or not. Current example for posterity:

{% if site.lang == "sv" %}
  {% capture link1 %}{{ site.baseurl_root }}en{{ page.url}}{% endcapture %}
  <a href="{{ link1 }}" >{% t global.english %}</a>
{% elsif site.lang == "en" %}
  {% capture link2 %}{{ site.baseurl_root }}{{ page.url  }}{% endcapture %}
  <a href="{{ link2 }}" >{% t global.swedish %}</a>
{% endif %}

In my example I have default lang en, secondary fi. If you click language switcher from default e.g. /help/ You will end up at: /help/fi/help/ Whereas the expected would be: /fi/help/ or if defining a permalink_fi: /apua/ then I would expect it to lead to /fi/apua/

So in short, the example switcher doesn't work with permalinks or translated permalinks and I couldn't fiddle it to work with them on my own.

dcram commented 7 years ago

I have exactly the same existential question about switching between languages in a permalinked page.

Any suggestion about how to do that ?

ghost commented 7 years ago

This works for me !

https://github.com/Anthony-Gaudino/jekyll-multiple-languages-plugin/pull/53