Skip to content

Commit

Permalink
Fix language selector when default language is not English
Browse files Browse the repository at this point in the history
Signed-off-by: hossainemruz <[email protected]>
  • Loading branch information
hossainemruz committed May 10, 2024
1 parent 3edd8e7 commit 8f095e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions exampleSite/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ module:
# For any more details, you can check the official documentation: https://gohugo.io/content-management/multilingual/
languages:
en:
languageCode: en
languageName: English
title: "John's Blog"
weight: 1
bn:
languageCode: bn
languageName: বাংলা
weight: 3
title: "জনের ব্লগ"
weight: 2

# Force a locale to be use, really useful to develop the application ! Should be commented in production, the "weight" should rocks.
# DefaultContentLanguage: bn
# default language for the content
defaultContentLanguage: en

# Allow raw html in markdown file
markup:
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/navigators/lang-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</a>
<div class="dropdown-menu" aria-labelledby="languageSelector">
{{ range site.Home.AllTranslations }}
<a class="dropdown-item nav-link languages-item" href="{{ path.Join "/" (cond (eq .Language.Lang "en") "" .Language.Lang) $pageURL }}">
<a class="dropdown-item nav-link languages-item" href="{{ path.Join "/" (cond (eq .Language.Lang $.Sites.First.Language.Lang) "" .Language.Lang) $pageURL }}">
{{ if ne site.Params.features.flags.enable false }}
{{ $countryCode := partial "helpers/country-code.html" . }}
<span class="flag-icon flag-icon-{{$countryCode}}"></span>
Expand Down

0 comments on commit 8f095e2

Please sign in to comment.