Skip to content
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

Merged
merged 1 commit into from Jul 8, 2018
Merged

Add language-selector for multilingualism #40

merged 1 commit into from Jul 8, 2018

Conversation

wasinski
Copy link
Contributor

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.

@luizdepra
Copy link
Owner

luizdepra commented Jul 2, 2018

Could you provide the configuration required to use the multilingual feature?
I was unable to figure out how to show two (or more) languages alongside the menu.

Also, could you edit the README and explain how to use the feature?

@luizdepra
Copy link
Owner

And, please, add yourself into the Readme's contributors section.

Copy link
Contributor

@khos2ow khos2ow left a 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.

@@ -1,16 +1,28 @@
<nav class="navigation">
<section class="container">
<a class="navigation-title" href="{{ .Site.BaseURL }}">
<a class="navigation-title" href="{{ .Site.Language }}">
Copy link
Contributor

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 }}.

{{ .Site.Title }}
</a>
{{ with .Site.Menus.main }}
{{ if .Site.Menus.main }}
Copy link
Contributor

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).

@wasinski wasinski closed this Jul 7, 2018
@wasinski wasinski reopened this Jul 7, 2018
@wasinski
Copy link
Contributor Author

wasinski commented Jul 7, 2018

@luizdepra README updated,
@khos2ow huge thanks!

@luizdepra
Copy link
Owner

Thank you.

@luizdepra luizdepra merged commit f18b8c4 into luizdepra:master Jul 8, 2018
@luizdepra luizdepra mentioned this pull request Jul 9, 2018
khos2ow added a commit to khos2ow/hugo-coder that referenced this pull request Sep 2, 2018
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants