adfaure / kodama-theme

Theme for zola inspired by hugo academic theme.
https://adfaure.github.io/kodama-theme/
MIT License
18 stars 9 forks source link

i18n support #7

Open beling opened 1 year ago

beling commented 1 year ago

Hello,

I am trying to migrate my page from hugo + academic to zola + kodama. My page is in two languages. That is why I'm work on adding i18n support (see https://www.getzola.org/documentation/content/multilingual/) to your template. My fork is here: https://github.com/beling/kodama-theme Must changes are in nav.html.

Basic support is already working and functional. Please feel free to merge it if you wish. My fork should not change anything if the page is one language only.

My page, which still uses hugo+academic: http://pbeling.w8.pl/ (however it is partially broken after upgrading hugo and forced upgrading academic; that is why I migrate from academic; it requires too much work after each upgrade and becomes over-complicated)

Best regards and thank you for your great work! Piotr Beling

adfaure commented 1 year ago

Hello, thank you for your contribution! I'll look into asap!

I understand, this is exactly why I left hugo+academic theme; I wanted something simple that I can maintain myself.

Regards, Adrien

beling commented 1 year ago

Alternatively hold the merging for a while to see how these fixes work on my site. When and if I manage to migrate it.

beling commented 1 year ago

I just upload to http://pbeling.w8.pl/ my page after migration to zola with my fork of kodama. It still needs some polishing.

I've done much more changes than only i18n support in my fork of kodama https://github.com/beling/kodama-theme For instance I've added initial support for table of contents (generated for pages with extra.toc=true) and taxonomies, see for example: http://pbeling.w8.pl/tags/ http://pbeling.w8.pl/authors/ I've improved support for publication section. For example: bib data are read from any bib file with any name; authors can be get from taxonomies.authors array and then it is possible to click on author of publication. I've fixed some bugs.

I'm still going to change the theme. I am seriously thinking about changes to the look. Maybe I will drop tailwindcss (I do not like the prose look and I am not convinced by the philosophy of tailwindcss). But it certainly won't happen soon.

Thank you for your work. Please merge what you like from my changes.

adfaure commented 1 year ago

Hello, thank you for the update ! I will have time soon to read your code.

I'll look at what you did, and try to update my website to the new version. If it works without too many changes, I'll probably merge it. Is it still possible to completely ignore the i18n ? Or does it need to be setup even for mono-lang sites ?

I should also update the readme to explain how to setup multiple language. Maybe, we can then push a new version to zola official website; to reflect your changes.

I don't mind dropping tailwind, but I don't have any better alternative in mind.

Here, I want to list few things that I had in mind doing this theme:

beling commented 1 year ago

I'll look at what you did, and try to update my website to the new version. If it works without too many changes, I'll probably merge it.

Note that I've changes some details in look, for example publications in summary.

Is it still possible to completely ignore the i18n ? Or does it need to be setup even for mono-lang sites ?

You cannot completely ignore the i18n. You must have this in config.toml:

[translations]
Biography = "Biography"
Interests = "Interests"
Education = "Education"
toc = "Table of Contents"
Published = "Published"
Abstract = "Abstract"
volume = "volume"
number = "number"
pages = "pages"

Which is required as I use https://www.getzola.org/documentation/templates/overview/#trans which crashes when cannot find the key. However, this is actually very useful also on mono-lang sites, if the lang is different from english, as it enables translations of strings inside the template.

I should also update the readme to explain how to setup multiple language. Maybe, we can then push a new version to zola official website; to reflect your changes.

I think that zola documentation is fine: https://www.getzola.org/documentation/content/multilingual/ However it misses one information, that default_language must by defined in config.toml of multi-lang site.

I don't mind dropping tailwind, but I don't have any better alternative in mind.

Here, I want to list few things that I had in mind doing this theme:

* The theme should be as simple as possible and easy to use (dropping tailwind might help here as I found it rather complicated).

I absolutely agree. For example, I don't need and don't have npm.

* I wanted it to be working fine without js. Though it is possible to add some using a customized header (like so: https://github.com/a-t-richard/a-t-richard.github.io/blob/master/templates/macros/katex.html)

I'm thinking of writing the CSS by hand, using only some minimalist framework. See for example Base, Class-less, and Very Lightweight categories here: https://github.com/troxler/awesome-css-frameworks I have no experience with any of them.

I think ultimately JS should possibly be included, but only conditionally (dependent on configuration) when the user needs maths (katex) or search. I don't need either at the moment.

beling commented 1 year ago

I've found the tool, that makes tailwind a bit better for me: https://github.com/pintariching/railwind

adfaure commented 1 year ago

Hello, thank your for your contribution I merged everything. It takes time to wrap up everything, but 'ill eventually release V2 of the theme. Here the changelog: https://github.com/adfaure/kodama-theme/blob/main/CHANGES.md#unreleased

I had to do some small change regarding the way we find translation to be able to have pages that are not translated.

I did not make any progress on the tailwind/no tailwind for now, but I have a question from another user regarding the color of the site, so I might advance on that concern .

Thanks again for your contribution ;)

beling commented 1 year ago

Great. Note that my patches add some more features, like table of content (enabled per page by extra.toc=true). I looked over your changes. Adding all languages to the menu is a good idea. However, I don't like the behavior when the site is untranslated. The link to the home page is confusing to me. I would display the annealed, non-clickable language name instead. And if there must be a link, how about a crossed-out one?

adfaure commented 1 year ago

Thanks, I will add the new features to the changelog.

I am not sure to understand, you mean the behavior when:

  1. go on untranslated page (like https://adfaure.github.io/fr/teaching)/
  2. click on en from the top right link,
  3. it brings you back to the home page (of the language you just clicked)

I agree, that's confusing for visitors.

I guess, a way to solve that would be to generate a page with content such as : "this page does not exist in this language (or something like this)". Idk if it is possible. Or, also a crossed-out link as you suggested (but I wanted to be able to change the language at any page so peoples that doesn't speak the current lang don't get lost).

I'll work on that when I have a bit of time.

beling commented 1 year ago

Yes, this is exactly the scenario I meant.