minimal-mistakes icon indicating copy to clipboard operation
minimal-mistakes copied to clipboard

Using locale & language tags from page instead of site

Open alloystorm opened this issue 1 year ago • 3 comments

This is an enhancement or feature.

Summary

By using the locale tag from the page, it allows different language pages on the same site.

Context

Previously it only allows a site to have only one language, which limits the ability to create multi-lingo sites.

With this proposed change, the pages are rendered using the locale tag from the page front matter, so that you can create pages for different languages on your website.

alloystorm avatar Jan 31 '24 13:01 alloystorm

I have my website running with this change.

For example this page: https://vrstormlab.com/dancexr/ Click on one of the language links below the title and you'll land on a new page with the same content but for a different language. The locale and lang tags are set correctly for each page so that the browser can recognize.

alloystorm avatar Jan 31 '24 13:01 alloystorm

I don't think page.locale propagates from site.locale. This means existing users who don't have proper page.locale will suddenly find their site back in English. If the fallback to site.locale is taken care of, I'll be OK with this PR.

iBug avatar Apr 22 '24 19:04 iBug

Here's my new idea: Since all templates end up being rendered in default.html, we can assign our desired variables in default.html and use it everywhere. Something like:

<!-- _layouts/default.html -->
{% assign locale = page.locale | default: site.locale %}

<!-- everywhere else -->
{{ site.data.ui-text[locale].blahblahblah }}

If you'd like to proceed, consider taking this approach or we can discuss another idea that you find better.

iBug avatar Jun 21 '24 11:06 iBug