Only show the available translation for the posts

This commit is contained in:
Emruz Hossain 2020-09-04 21:54:50 +06:00
parent dbff898bf3
commit 856a1b185f
8 changed files with 61 additions and 9 deletions

View file

@ -12,6 +12,9 @@ languages:
fr:
languageName: Français
weight: 2
bn:
languageName: বাংলা
weight: 3
# Force a locale to be use, really useful to develop the application ! Should be commented in production, the "weight" should rocks.
#DefaultContentLanguage: fr

30
i18n/bn.toml Normal file
View file

@ -0,0 +1,30 @@
# More documentation here: https://github.com/nicksnyder/go-i18n
[home]
other = "হোম"
[posts]
other = "পোষ্ট সমূহ"
[resume]
other = "আমার জীবনবৃত্তান্ত"
[navigation]
other = "নেভিগেশন"
[contact_me]
other = "আমার সাথে যোগাযোগ করুনঃ"
[newsletter_text]
other = "ইমেইল নোটিফিকেশান এর মাধ্যমে সর্বশেষ তথ্য জানুন"
[newsletter_input_placeholder]
other = "ইমেইল প্রবেশ করান"
[newsletter_warning]
other = "আমরা আপনার ইমেল অন্য কারও সাথে শেয়ার করব না।"
[submit]
other = "জমা দিন"
[hugoAttributionText]
other = "পাওয়ারড বাই"

View file

@ -2,6 +2,9 @@
[home]
other = "Home"
[posts]
other = "Posts"
[resume]
other = "My resume"

View file

@ -2,6 +2,9 @@
[home]
other = "Accueil"
[posts]
other = "Des postes"
[resume]
other = "Mon Curriculum vitæ"

View file

@ -13,7 +13,7 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" />
<!--================= fab-icon =========================-->
<link rel="icon" type="image/png" href="{{ .Site.Params.logo.favicon | default "/assets/images/favicon.png"}}" />
<link rel="icon" type="image/png" href="{{ .Site.Params.logo.favicon | default "/assets/images/favicon.png" | absURL }}" />
<!--================= custom style overrides =========================-->
<link rel="stylesheet" href="/assets/css/style.css" />

View file

@ -0,0 +1,13 @@
{{ $languageCode:= .Lang }}
{{/* by default the language code and the country code are same */}}
{{ $countryCode:= $languageCode }}
{{/* language code and country code are not same for some countries. we need to fix them. */}}
{{ if eq $languageCode "en" }}
{{ $countryCode = "gb" }}
{{ else if eq $languageCode "bn" }}
{{ $countryCode = "bd" }}
{{ end }}
{{/* return the country code */}}
{{ return $countryCode }}

View file

@ -30,14 +30,14 @@
{{ if .IsTranslated }}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="languageSelector" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img class="flag" src="https://www.countryflags.io/{{ cond (eq .Site.Language.Lang "en") "gb" .Language }}/flat/16.png">
{{- .Site.Language.LanguageName -}}
<img class="flag" src="https://www.countryflags.io/{{ partial "helpers/country-code.html" .Language }}/flat/16.png">
{{ .Site.Language.LanguageName }}
</a>
<div class="dropdown-menu" aria-labelledby="languageSelector">
{{ range $.Site.Home.AllTranslations }}
{{ range .Translations }}
<a class="dropdown-item nav-link languages-item" href="{{ path.Join "/" (cond (eq .Language.Lang "en") "" .Language.Lang) $pageURL }}">
<img class="flag" src="https://www.countryflags.io/{{ cond (eq .Site.Language.Lang "en") "gb" .Language }}/flat/24.png">
{{- .Language.LanguageName -}}
<img class="flag" src="https://www.countryflags.io/{{ partial "helpers/country-code.html" .Language }}/flat/24.png">
{{ .Language.LanguageName }}
</a>
{{ end }}
</div>

View file

@ -53,7 +53,7 @@
{{ end }}
{{ if site.Params.enableBlogPost }}
<li class="nav-item">
<a class="nav-link" id="blog-link" href="/posts">Posts</a>
<a class="nav-link" id="blog-link" href="/posts">{{ i18n "posts" }}</a>
</li>
{{ end }}
{{ range (index .Site.Data .Site.Language.Lang).site.customMenus }}
@ -64,13 +64,13 @@
{{ if .IsTranslated }}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="languageSelector" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img class="flag" src="https://www.countryflags.io/{{ cond (eq .Site.Language.Lang "en") "gb" .Language }}/flat/16.png">
<img class="flag" src="https://www.countryflags.io/{{ partial "helpers/country-code.html" .Language }}/flat/16.png">
{{ .Site.Language.LanguageName }}
</a>
<div class="dropdown-menu" aria-labelledby="languageSelector">
{{ range $.Site.Home.AllTranslations }}
<a class="dropdown-item nav-link languages-item" href="{{ .Permalink }}">
<img class="flag" src="https://www.countryflags.io/{{ cond (eq .Site.Language.Lang "en") "gb" .Language }}/flat/24.png">
<img class="flag" src="https://www.countryflags.io/{{ partial "helpers/country-code.html" .Language }}/flat/24.png">
{{ .Language.LanguageName }}
</a>
{{ end }}