zjedi / hugo-scroll

Clean, responsive, single-page Hugo website theme.
https://themes.gohugo.io/hugo-scroll/
MIT License
256 stars 187 forks source link

Suggestion for multi lang menu #177

Closed ilja-radusch closed 1 month ago

ilja-radusch commented 3 months ago

This is a quick suggestion for a language selection menu right below the site menu. This pulls the currently configured languages to display the menu.

Two new site params are used:

language_menu = true
show_current_lang = false

which control the overall rendering of the language menu and whether the current language should be rendered or omitted.

I could not style the language menu any further. Another idea would be to put that into the footer or at the top of the page.

Hope this helps.

zjedi commented 3 months ago

Can you please make changes also to exampleSite so that the feature is demonstrated? It's totally ok if the content is not translated at the moment, but it would be nice to demonstante the feaature and see it also in the netlify pull request preview.

zjedi commented 3 months ago

I can look into styling it further, if you dont mind me contributing to this branch.

ilja-radusch commented 3 months ago

Would welcome that.

On 18. Mar 2024, at 22:27, zjedi @.***> wrote:



I can look into styling it further, if you dont mind me contributing to this branch.

— Reply to this email directly, view it on GitHubhttps://github.com/zjedi/hugo-scroll/pull/177#issuecomment-2005029964, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVLSKK4R6V5IEI3OJAYDERTYY5L4RAVCNFSM6AAAAABE4LPJTKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBVGAZDSOJWGQ. You are receiving this because you authored the thread.Message ID: @.***>

zjedi commented 3 months ago

I quickly checked how this language swithing looks and I'm thinking ... 1) is it enough to support just two laguages for now? Are two enough for you? 2) for the future, we will eventually need to support 3+ languages, which involves a dropdown and somewhat more complex logic. But we can do it later when the need arises.

ilja-radusch commented 3 months ago

Right now the is room for more languages as they just all sit on the top. four or five and you can make more room if you don’t show the current language. Four or five languages is enough for me. Longer language list like 10+ would definitely need something else.

However, this is completly up to taste. I just did some quick styling with what was available already. :-)

You can add an option to put the language list in the footer as a drop-down menu.

On 24. Mar 2024, at 23:01, zjedi @.***> wrote:

I quickly checked how this language swithing looks and I'm thinking ...

  1. is it enough to support just two laguages for now? Are two enough for you?
  2. for the future, we will eventually need to support 3+ languages, which involves a dropdown and somewhat more complex logic. But we can do it later when the need arises.

— Reply to this email directly, view it on GitHubhttps://github.com/zjedi/hugo-scroll/pull/177#issuecomment-2016959236, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVLSKKYJ65D7KBXMFHWJQMTYZ5EMFAVCNFSM6AAAAABE4LPJTKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJWHE2TSMRTGY. You are receiving this because you authored the thread.Message ID: @.***>

zjedi commented 3 months ago

Thanks, the language switching menu moved toward top right corner looks much better, I think we could have it this way for the moment. Quick test: There are still some issues with images: cover image, in-content images, quotation marks, icons in contact section (newly available also is footer) Linksto images are somehow broken.

ilja-radusch commented 3 months ago

Some images use ../images/ to reference. Should be changed to just images/

Also some images are missing (I.e. those from services.md)

Additionally, images might need resources.Get magic to work. I corrected that with the header_logo already. This way, the image gets copied for sure. assets are not copied to public if they are not used/referenced

On 24. Mar 2024, at 23:31, zjedi @.***> wrote:



Thanks, the language switching menu moved toward top right corner looks much better, I think we could have it this way for the moment. Quick test: There are still some issues with images: cover image, in-content images, quotation marks, icons in contact section (newly available also is footer) Linksto images are somehow broken.

— Reply to this email directly, view it on GitHubhttps://github.com/zjedi/hugo-scroll/pull/177#issuecomment-2016968766, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVLSKK6YKQ2YNSKFMDUTWY3YZ5H2RAVCNFSM6AAAAABE4LPJTKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJWHE3DQNZWGY. You are receiving this because you authored the thread.Message ID: @.***>

zjedi commented 3 months ago

Looks much better, we just have to sort out broken images.

zjedi commented 1 month ago

@ilja-radusch I'm checking out the image problem and I wonder, what is the idea behind moving images from static to assets? Because I can't get the images from assets get properly loaded when internationalized. It does work from static though.

It looks like the global stuff goes under assets, but the i18n content (homepage) needs to either stay in static or be under language-specific folders.

ilja-radusch commented 1 month ago

Hugo checks if the images in assets are referenced and will only copy those accessed/used by the site.

Also all resources.Get functions will need the images to be in the assets directory. Without utilizing resources, getting a .PermaLink or .RelLink is not possible. This is what we wanted in the start.

However, you have to make sure all resources are referenced or .Publish

On 11. May 2024, at 01:14, zjedi @.***> wrote:



@ilja-raduschhttps://github.com/ilja-radusch I'm checking out the image problem and I wonder, what is the idea behind moving images from static to assets? Because I can't get the images from assets get properly loaded when internationalized. It does work from static though.

— Reply to this email directly, view it on GitHubhttps://github.com/zjedi/hugo-scroll/pull/177#issuecomment-2105371462, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVLSKK7JX5HSK42DOIPTGQ3ZBVIDPAVCNFSM6AAAAABE4LPJTKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBVGM3TCNBWGI. You are receiving this because you were mentioned.Message ID: @.***>

zjedi commented 1 month ago

@ilja-radusch Thanks for explanation. I can see the following way forwards:

A fix for the broken images would be either:

A. move content-related images back to static Suitable when you want to reuse the same image for all languages.

B. move content-related images to content folders. Suitable if you have language-dependent variants of the content images.

C. create shortcode for including images from assets I'm not very fond of this approach, since it's a step away from generic markdown and towards hugo specific code. But I can see some advanced users might like it.

Maybe we can revisit the topic in a separate PR that would be focused on moving these images to assets - I tried and failed to use them from assets folder. Simple (img)[...jpg] in an .md file won't work - but that's a basic image linking feature that should be preserved. I'm not sure why it doesn't work out of the box, but there are others struggling with this, too.

I plan pushing example for both A and B for german language, and moving some of the images back to static. That would unblock merging this feature.

zjedi commented 1 month ago

Ok, it seems that in the latest 10 versions, this must have changed, I just updated to latest Hugo version (0.125) and getting different results regarding image linking. Previously I was on something like 0.11x

zjedi commented 1 month ago

@ilja-radusch I've played around with various approaches and documented possible ways of localizing markdown and images. Local preview does look fine to me, but the Netlify preview won't render the images from assets. https://deploy-preview-177--hugo-scroll.netlify.app/de/

Have you published your site already somewhere, or do you have it only locally in development?