Fix language selector when default language is not English (#936)

Signed-off-by: hossainemruz <hossainemruz@gmail.com>
This commit is contained in:
Emruz Hossain 2024-05-11 01:59:04 +06:00 committed by GitHub
parent 3edd8e7858
commit a3213b46f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View file

@ -33,14 +33,18 @@ module:
# For any more details, you can check the official documentation: https://gohugo.io/content-management/multilingual/ # For any more details, you can check the official documentation: https://gohugo.io/content-management/multilingual/
languages: languages:
en: en:
languageCode: en
languageName: English languageName: English
title: "John's Blog"
weight: 1 weight: 1
bn: bn:
languageCode: bn
languageName: বাংলা 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. # default language for the content
# DefaultContentLanguage: bn defaultContentLanguage: en
# Allow raw html in markdown file # Allow raw html in markdown file
markup: markup:

View file

@ -12,7 +12,7 @@
</a> </a>
<div class="dropdown-menu" aria-labelledby="languageSelector"> <div class="dropdown-menu" aria-labelledby="languageSelector">
{{ range site.Home.AllTranslations }} {{ 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 }} {{ if ne site.Params.features.flags.enable false }}
{{ $countryCode := partial "helpers/country-code.html" . }} {{ $countryCode := partial "helpers/country-code.html" . }}
<span class="flag-icon flag-icon-{{$countryCode}}"></span> <span class="flag-icon flag-icon-{{$countryCode}}"></span>