New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add language-selector for multilingualism #40
Conversation
Could you provide the configuration required to use the multilingual feature? Also, could you edit the README and explain how to use the feature? |
And, please, add yourself into the Readme's contributors section. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Big +1 on the effort, I've done this on my own fork but haven't had the time to open a PR. Although I believe this PR requires a little bit of refactoring.
layouts/partials/header.html
Outdated
@@ -1,16 +1,28 @@ | |||
<nav class="navigation"> | |||
<section class="container"> | |||
<a class="navigation-title" href="{{ .Site.BaseURL }}"> | |||
<a class="navigation-title" href="{{ .Site.Language }}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The href
here can be written as {{ print "/" | absLangURL }}
.
layouts/partials/header.html
Outdated
{{ .Site.Title }} | ||
</a> | ||
{{ with .Site.Menus.main }} | ||
{{ if .Site.Menus.main }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this whole block can be done as follow, IMO it's cleaner and without the repetition of language-selector.html
:
<ul class="nav navbar-nav {{ if $.Site.Params.rtl }} navbar-left {{ else }} navbar-right {{ end }}">
{{ with .Site.Menus.main }}
{{ range sort . }}
<li>
<a href="{{ .URL | absLangURL }}">{{ i18n .Name }}</a>
</li>
{{ end }}
{{ end }}
{{ if .Site.IsMultiLingual }}
{{ $node := . }}
{{ .Scratch.Set "separator" true }}
{{ range .Site.Home.AllTranslations }}
{{ $language := printf "%s" .Language }}
{{ if ne $.Site.Params.Langcode $language }}
{{ if $node.Scratch.Get "separator" }}
<li>
<span>|</span>
</li>
{{ $node.Scratch.Set "separator" false }}
{{ end }}
<li>
<a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
</li>
{{ end }}
{{ end }}
{{ end }}
</ul>
I personally don't like the separator, but I added it here as an example (and it would be cool to make that configurable).
@luizdepra README updated, |
Thank you. |
* Add avatar option and footer text option (luizdepra#41) * Add avatar option and footer text option * add responsive avatar for narrow screen * improvement of code * conflicts solved * Add support for multilingualism (luizdepra#40) * Improve README.md * Mobile menu (luizdepra#63) * mobile menu functional * mobile menu beta * edits mobile-menu: home link out, rtl ok, menu pop over * mobile menu - bugs correction * add horizontal separator * corrections done + add configuration of centered or rtl/ltr mobile menu * edit config of example * separator padding full * Update logos and screenshots * Add style enhancements for AsciiDoc (luizdepra#67) * Add SCSS via Asset Pipeline (luizdepra#65) * Remove old files * Add SCSS pipeline * Add generated files * Fix navigation HTML * Fix media queries * Remove RTL * Fix styling for big screens * Remove separator configs * Fix menu dropdown * Add working mobile menu * Fix menu item heights * Update README * Improve README. * Remove resources folder * Add social icons * Enable RTL layout by providing 'rtl = true' in the config (luizdepra#72) * Use Hugo asset pipelines
As I said it's not pretty. A lot of code is added just to have a
|
between menus and languages. I also tried to hide current language in the selector but I wasn't able to do it.