Access language params from config

I have this in my site config file
[languages.de]
title = "Title"
weight = 2
[languages.de.params]
languagecode = "de"
foo = “bar”

When I try to access the ‘languagecode’ from the template like this
.Site.Language.Params.languagecode
Ι don’t get anything. When debugging it says it with printf it says it is a map.

How can I access my params specific for each language in my template?

1 Like

It looks correct, which means there must be something else wrong. (which is hard to see without seeing the complete picture).

But also note that

{{ .Site.Language.Lang }}

Should contain “de” in this case.

Thank you bep.

I know about .Site.Language.Lang but I need more custom params

This is the whole config.toml

baseurl = “https://wwww

theme = "custom"
languageCode = “en-us”

disqusShortname = “”

paginate = 10

[params]
copyright = "Copyright © 2015 - 2017"
date_format = "2006-01-02"
logo = "img/Logo_Img.png"
sponsor_logo = “img/erasmus_plus_logo.png”

[params.carousel]
enable = true

defaultContentLanguage = “en”

[languages]

[languages.en]
weight = 0
[languages.en.params]
languagecode = “en”

[[languages.en.menu.main]]
name = "Project"
url = "/project/"
weight = 0

[[languages.en.menu.main]]
name = "Products"
url = "/products/"
weight = 1

[[languages.en.menu.main]]
name = "Partners"
url = "/partner/"
weight = 2

[[languages.en.menu.main]]
name = "News"
url = "/news/"
weight = 3

[[languages.en.menu.main]]
name = "Contact"
url = "/contact/"
weight = 4

[[languages.en.menu.language]]
name = "German"
url = "/de"
pre = "   "
weight = 0

[[languages.en.menu.language]]
name = "Greek"
url = "/el"
pre = "   "
weight = 1

[[languages.en.menu.language]]
name = "Dutch"
url = "/nl"
pre = "   "
weight = 2

[[languages.en.menu.language]]
name = "Slovak"
url = "/sk"
pre = "   "
weight = 3

[[languages.en.menu.language]]
name = "Slovenian"
url = "/sl"
pre = "   "
weight = 4

[[languages.en.menu.language]]
name = "Spannish"
url = "/es"
pre = "   "
weight = 5

And in my template I do this

<div class="pull-right lang-selector">
    <div class="dropdown">
        <div class="dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
            <span class='flag-icon flag-icon-{{ .Site.Language.Params.langcode }}'></span>
            <span class="caret"></span>
        </div>
        <ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenu1">
            {{ range .Site.Menus.language }}
                <li><a href="{{ .URL }}">{{ .Pre }}{{ .Name }}</a></li>
            {{ end }}
        </ul>
    </div>
</div>

The .Site.Language.Params.langcode in not working in this case.

Were you able to solve this? I have the same issue.

In my config.json

{"params": 
    "menu": {
		"en": {
			"home": "Home",
			"tour": "Tour",
			"business": "Business",
			"pricing": "Pricing"
		"es": {
			"home": "HOME",
			"tour": "TOUR",
			"business": "BUSINESS",
			"pricing": "PRICING",
		}
	}
    }

And I want to do this:

<a href="/home">{{ .Site.Params.menu.(site language code here).home }}</a>

I’ve tried using

{{ $SiteLang := .Site.Language.Lang }} 
<a href="/home">{{ .Site.Params.menu.$SiteLang.menu }}</a>