List all translation, but not the active one

Hi, in my config.toml i have something like this:

[languages]
  [languages.en]
    weight = 1
    languageName = "English"
    languageNameShort = "en"
    languageCode = "en_US"
  [languages.de]
    weight = 2
    languageName = "Deutsch"
    languageNameShort = "de"
    languageCode = "de_DE"
[languages.fr]
    weight = 3
    languageName = "France"
    languageNameShort = "fr"
    languageCode = "fr_Fr"

I would like to display all language-codes, but the active language-code should not be
visible.

How would I have to change the following code for this to work?

{{ range sort .Site.Languages }}
{{ .Params.languageCode }}
{{ end }}

Try

{{ range site.Home.Translations }}
{{ end }}

I don’t understand. If i try your code i get something like: Page(/_index.en.md)

I’m not that pro in Go. So maybe i need more help :slight_smile:

{{ range site.Home.Translations }} {{ { .Title }}: {{ .RelPermalink }} {{ end }}

Thank you.

i tried this:

{{ range site.Home.Translations }} 
  {{ $lang := replace .RelPermalink "/" "" }}
  {{ range .Site.Languages }}
    {{ if eq $lang .Params.languageNameShort }}
      {{ .Params.languageCode }}
    {{ end }}
  {{ end }}
{{ end }}

Result:

  • de_DE
  • fr_FR
    when I’m on the english site.

If I go to the German or French site, he doesn’t show me en_US. How is that possible?

I got it!

{{ range site.Home.Translations }} 
  {{ $lang := .Lang }}
  {{ range .Site.Languages }}
    {{ if eq $lang .Params.languageNameShort }}
      <meta property="og:locale:alternate" content="{{ .Params.languageCode }}" />
    {{ end }}
  {{ end }}
{{ end }}

Thank you so much for your help!!!

I suspect you can do simpler:

{{ range site.Home.Translations }} 
      <meta property="og:locale:alternate" content="{{ .Language.Params.languageCode }}" />
{{ end }}
1 Like

Yep :laughing:
I didnt know how to access the info. Thank you.

1 Like

For completeness:

If you want to put the above in any of the page template, this will give the translation list for any page:

{{ range .Translations }} 
      <meta property="og:locale:alternate" content="{{ .Language.Params.languageCode }}" />
{{ end }}
2 Likes

Thank you. I’ll take care of it. Where would I have found this information in the documentation?