untra/polyglot

sample.md defines its language as site.data["active_lang"] but this may cause errors...

antoniovazquezblanco opened this issue · 5 comments

It turns out that if you print the lang variable at lib/jekyll/polyglot/patches/jekyll/site.rb in the function coordinate_documents the variable has not been evaluated in a context thus resulting in having the site.data["active_lang"] as a valid value...

This can cause problems if data is not defined for a single language...

The value of lang should be evaluated in context or lang may be changed to allow it to be a vector of valid langs...

This is preventing me from creating a liquid tag that can fetch file urls for different translations...

See https://github.com/antoniovazquezblanco/polyglot/tree/dev/linklang for the implementation of the liquid tag I am trying to create...

Thanks!

untra commented

I'm making some improvements for running rspec tests in ci.
master...antoniovazquezblanco:polyglot:dev/linklang#diff-4ba1e609c8b3d54fb7d83205ca7c2e807fe0bd93052f7ecd2ded36d49fdbe1e6R135-R140
your changes in site.rb seem necessary and make sense. If you can add more tests I'll feel better about getting changes out.

If you want to also contribute the LinkLang tag that would also be cool

Your latest changes crush it man!

I am thinking on contributing the linklang tag in order to provide linking without redirection but the current approach suits my needs!
Also, your recent changes allow me to implement the linklang tag in a more elegant way :D

Thanks!

untra commented

😁 Hell yeah, thanks again for your help @antoniovazquezblanco !

I changed the lang_id to page_id because it seemed to reduce visual confusion in the frontmatter and code.

The jekyll-redirect-from gem was something I had to recently study for work and I saw the complete implementation and goal. Different permalinks make language switching challenging, but automatically coordinating the redirects for corresponding pages is easily solvable.

The flexibility of that plugin to customize the redirect.html with polyglot conventions makes it all just work.

Thanks for your patience while I prepped the approach and release 👍

A new approach on how to implement the functionality I seek is proposed in #185.

This issue can be closed :)