From 856a1b185fd35b034aa7b7833ed2a4ed772cd35c Mon Sep 17 00:00:00 2001 From: Emruz Hossain Date: Fri, 4 Sep 2020 21:54:50 +0600 Subject: [PATCH] Only show the available translation for the posts --- exampleSite/config.yaml | 3 +++ i18n/bn.toml | 30 ++++++++++++++++++++++ i18n/en.toml | 3 +++ i18n/fr.toml | 3 +++ layouts/partials/header.html | 2 +- layouts/partials/helpers/country-code.html | 13 ++++++++++ layouts/partials/navigators/navbar-2.html | 10 ++++---- layouts/partials/navigators/navbar.html | 6 ++--- 8 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 i18n/bn.toml create mode 100644 layouts/partials/helpers/country-code.html diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 014f4d7..784f6b7 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -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 diff --git a/i18n/bn.toml b/i18n/bn.toml new file mode 100644 index 0000000..958f564 --- /dev/null +++ b/i18n/bn.toml @@ -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 = "পাওয়ারড বাই" diff --git a/i18n/en.toml b/i18n/en.toml index 5422b7a..6a5be72 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -2,6 +2,9 @@ [home] other = "Home" +[posts] +other = "Posts" + [resume] other = "My resume" diff --git a/i18n/fr.toml b/i18n/fr.toml index 1fcdd1d..7067bdd 100644 --- a/i18n/fr.toml +++ b/i18n/fr.toml @@ -2,6 +2,9 @@ [home] other = "Accueil" +[posts] +other = "Des postes" + [resume] other = "Mon Curriculum vitæ" diff --git a/layouts/partials/header.html b/layouts/partials/header.html index dcc7c33..1c565bb 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -13,7 +13,7 @@ - + diff --git a/layouts/partials/helpers/country-code.html b/layouts/partials/helpers/country-code.html new file mode 100644 index 0000000..c00c4e7 --- /dev/null +++ b/layouts/partials/helpers/country-code.html @@ -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 }} diff --git a/layouts/partials/navigators/navbar-2.html b/layouts/partials/navigators/navbar-2.html index b78ef96..c394491 100644 --- a/layouts/partials/navigators/navbar-2.html +++ b/layouts/partials/navigators/navbar-2.html @@ -30,14 +30,14 @@ {{ if .IsTranslated }} {{ end }} {{ range (index .Site.Data .Site.Language.Lang).site.customMenus }} @@ -64,13 +64,13 @@ {{ if .IsTranslated }}