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

Stay on current page when switching lang, improve button alignment & make text configurable #740

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion exampleSite/content/docs/multilingual/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,28 @@ for German website if those pages are not translated to German. For more
information on Hugo's Multilingual mode, please refer to [their documentation](https://gohugo.io/content-management/multilingual/).

In order to configure two languages, you need to update your main your
configuration. Here's an example from the official documentation:
configuration. Here's an example, derived from the official documentation:

```
DefaultContentLanguage = "en"

[languages]
[languages.en]
languageName = "English"
title = "My blog"
weight = 1
[languages.fr]
languageName = "Français"
title = "Mon blogue"
weight = 2

[params]
...
```

The `languageName` parameter is used as text on the language switcher buttons
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using i18n for this id being the language, but I think this is cleaner. We should open an issue tracking us to move from the i18n workaround to languageName globally in Syna.

in the navbar.

Please note that these parameters are added outside of `params` variable, inside
your configuration file (`config.toml`, `config.yaml`, `config.json`). This will
let Hugo know that there are two languages for this project and the default
Expand Down
8 changes: 4 additions & 4 deletions layouts/partials/fragments/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{{- else -}}
{{- printf " justify-content-end " -}}
{{- end -}} collapse show" id="navbarCollapse">
<ul class="navbar-nav">
<ul class="navbar-nav mr-2">
{{- if .Params.prepend -}}
{{- range sort .Params.prepend }}
{{- $isMenuCurrent := or (eq $.root.Permalink .url) (eq (printf "%s/" $.root.Permalink) .url) (eq $.root.Permalink (printf "%s/" .url)) -}}
Expand Down Expand Up @@ -101,9 +101,9 @@
</div>
{{- end }}
{{- if .Site.IsMultiLingual -}}
{{- range .Site.Languages }}
<a class="btn btn-secondary p-1 m-1" href="{{ delimit (slice "/" .) "" }}" role="button">
{{ . }}
{{- range $.root.Page.Translations }}
<a class="btn btn-secondary mr-1 my-2" href="{{ .Permalink }}" role="button">
{{ .Language.LanguageName }}
</a>
{{- end -}}
{{- end }}
Expand Down