Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple-language on Github-Pages

A long time I don't acess my page http://andeon.github.io/askey/apps/gimp/ so, yesterday I checked that the translations not works more for keyboard pages, there was update on github-pages?

Repository structure : github.com/andeon/askey/tree/gh-pages

- |-- _includes/      # Html rendered 
- |-- _layouts/       # Templates of the website
-   |--  dic/         # keyboards translation
- |-- index.html      # Default html file (EN)
- |-- pt              # Portuguese Language files
- |-- (...)
- |-- _config.yml     # Jekyll configuration file

The file "_includes/gimp_keyboard.html" use the variable page.t[page.lang].($variable) to link the translation in "dic/gimp_en.md" or "dic/gimp_pt.md" etc, that's what translated the tooltips of keys and pop-ups.

Structure of Gimp_en.yml:

layout: main_gimp
t:
 en:
  tooltip_esc: "Close Dialogs"
  tooltip_f1: "Help"

ex: gimp_keyboard.html Esc key tooltip:

<a href="#popup_esc" class="key c27 fn" data-tooltip="{{ page.t[page.lang].tooltip_esc }}"><span>esc</span>

And Pop-up key w

<div id="popup_w" class="overlay"> <div class="popup"> <h2>{{ site.t.l_popupt[page.lang] }}</h2> <a class="close" href="#" onclick="history.back(); return false;">×</a> <div class="content"> <table class="tftable" border="1"> {{ site.t.l_thc[page.lang] }} {{ page.t[page.lang].key_w }}

*The global translation of variable "site.t.(...)[page.lang]" bound inside _config.yml are working.

I don't have idea how fix it. Maybe it not was smart way to make multiple-language with a trick of "dictionary file" (but here the reason https://github.com/andeon/askey/wiki I need the variables to create an easier way to do translations).

Does anyone have any idea to fix or another suggestion?

I'd used this site for reference for create the page: benoitpatra.com/2014/08/24/organize-a-multilanguage-jekyll-site/

like image 920
AndeOn Avatar asked Oct 19 '22 07:10

AndeOn


1 Answers

Yes it's a change between Jekyll 2.x an Jekyll 3.x that is now in use at github.

Your language string are in a layout. eg: gimp.html has dic/gimp_en as layout, which itself has languages strings in his front matter under the t key.

With jekyll 2.x, a layout variable was passed through the template cascade in the page variable. You accessed it with page.t

Now with jekyll 3.x, a template variable is passed in the layout variable. You access it with layout.t

If you replace all your page.t occurrences by layout.t, the magic will happen again.

Side note : You can centralize all your language strings in data files. English strings in _data/lang/en/gimp.yml and Portuges in _data/lang/pt/gimp.yml and access them with site.lang[page.lang].

And you can then remove the intermediary dic/gimp_xx layout.

This will be more future proof.

like image 149
David Jacquel Avatar answered Jan 04 '23 07:01

David Jacquel