Multiligual support with multiple config files

Hi,

I used Hugo with prior version to 112 and multiples config files in directory config/_default:
config.toml

baseURL = "https://domaine.com"
languageCode = "fr-be"
title = "Centre"
subTitle = "L'oeil"
theme = "mamisoa-hugo"
defaultContentLanguage = "fr"
defaultContentLanguageInSubdir = true

languages.toml

[fr]
    description = "Le Centre Médical "
    title = "Centre Médical"
    contentDir = "content/fr"
    subTitle = "L'oeil est la fenêtre de l'Ame"
    weight = 1
[en]
    description = "Medical Center ."
    title = "Medical Center"
    subTitle = "The eye is the window of the Soul"
    contentDir = "content/en"
    weight = 2
[nl]
    description = "Het Medisch Centrum"
    title = "Medisch Centrum "
    subTitle = "Het oog is het venster van de ziel"
    contentDir = "content/nl"
    weight = 3
[fr.menu.main]]
identifier = "accueil"
name = "Accueil"
title = "Accueil"
url = "/"
weight = 1
[[fr.menu.main]]
identifier = "covid-19"
name = "covid19"
title = "Covid-19"
url = "/faq/covid19"
weight = 2
[[en.menu.main]]
identifier = "accueil"
name = "home"
title = "Home"
url = "/en"
weight = 1
[[en.menu.main]]
identifier = "faq"
name = "faq"
title = "Frequently Asked Questions"
url = "/en/faq"
# cut

and params.toml

description = "Centre Médical"
logo = "images/logo/oeil_from_fw_h75px.png"
license = "Copyright © 2023 - Mamisoa"
author = "Mamisoa"
author_pic = "images/team/profil_mamisoa_150x150.jpg"
env = "production"
mono = "no"

Playing locally, I had to add in params:

defaultContentLanguageInSubdir = true

to make the multilingual routing work.
My questions is: “How should I convert the languages.toml file ? Should I put all in the params file ?”
I kept in the file the items: fr.menu en.menu nl.menu and moved the item fr en nl to params, it kinda works.
But the description is not updating, just using the main description “Centre Médical”. It is called in the template as this:

    <meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">

What is the best new practice ?

Mamisoa

See the second example:
https://gohugo.io/content-management/multilingual/#configure-languages

Put language-specific, user-defined parameters under [languages.xx.params].

For those who are using a separate languages.toml file, this is the format to go:

[fr]
    title = "Centre Médical"
    contentDir = "content/fr"
    weight = 1
    [fr.params]
        description = "Le Centre Médical"
        subTitle = "L'oeil est la fenêtre de l'Ame"
[en]
    description = "Medical Center"
    title = " Medical Center"
    contentDir = "content/en"
    weight = 2
    [en.params]
        description = "Medical Center"
        subTitle = "The eye is the window of the Soul"

[nl]
    title = "Medisch Centrum"
    contentDir = "content/nl"
    weight = 3
    [nl.params]
        description = "Het Medisch Centrum "
        subTitle = "Het oog is het venster van de ziel"
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.