untra / polyglot

:abc: Multilingual and i18n support tool for Jekyll Blogs
https://polyglot.untra.io
MIT License
416 stars 59 forks source link

how do I enable a language toggle on my website #109

Closed rnagais2 closed 4 years ago

rnagais2 commented 4 years ago

Hallo,

I wanted to make a multilingual website in English (default), German, and Japanese. As guided in this official page, I have made corresponding files:

_posts/2020-04-11-welcome-de.md
_posts/2020-04-11-welcome-en.md
_posts/2020-04-11-welcome-ja.md

but the website shows the three different posts: https://kokuryu-muenchen.de/

How can the website shows only default page and have a translation button like this sample (https://polyglot.untra.io/)?

My repository is https://github.com/rnagais2/kokuryu-muenchen.de

untra commented 4 years ago

Hi @rnagais2 👋

the site branch of the polyglot repo is actually the jekyll project for the polyglot.untra.io site.

On my website, I have this language toggle setup in the sidebar.

all it takes for me is this bit of liquid syntax: https://github.com/untra/polyglot/blob/site/_includes/sidebar.html#L40-L42

try putting that in your header for a translation button. And refer to that branch for more clues on how to structure your site.

rnagais2 commented 4 years ago

Hi @untra

Many thanks to your help.

I could enable a language toggle on my website. Locally it works with no problem.

However, after I uploaded on Github page, the website does not work with plugin (https://kokuryu-muenchen.de/). The main language (en, English) includes pages that was set for other language (ja = Japanese, de=german) and when I click other language, the page is not found.

Do you have any idea?

My repository is https://github.com/rnagais2/kokuryu-muenchen.de

untra commented 4 years ago

I totally know why. @rnagais2 this is because polyglot is not a github whitelisted gem. I would need to make some adjustments to the code and jump through some support hoops to get this privilege.

Basically github will build your website on gh-pages without the jekyll-polyglot gem, which is pretty lame 👎 but its for legitimate security reasons; github is running ruby code in a sandbox environment to build websites on commits for free, so they naturally want to restrict what code gets run in these builds.

The intended use of this gem with github pages is to build your website locally, and push your built website up to the gh-pages branch, rather than host the site from the gh-pages branch (although that is mighty convenient). I do this with a shell script, which could work for you as well.