I18n issue in fetching the de-language

WARN  Failed to get translated string for language "de" and ID "home.desc": %!s(<nil>)
WARN  Failed to get translated string for language "de" and ID "home.signup": %!s(<nil>)
WARN Failed to get translated string for language "de" and ID "home.signin": %!s(<nil>)

Configuration file:

baseURL: "https://www.example.com"
title: " Web site"
MetaDataFormat: "yaml"
contentdir: "content"
layoutdir: "layouts"
publishdir: "public"
uglyURLs: true
disableKinds: ["RSS","sitemap","taxonomy","section"]
watch: false
ignoreErrors : ["error-disable-taxonomy"]

markup:
  goldmark:
    renderer:
      unsafe: true

Languages:
  en:
    language: "english"
  fr:
    language: "french"
  de:
    language: "deutsch"
    weight: 1
  de-de:
    language: "deutsch-de"
    params:
        langCode: "de-de"
 weight: 2

Hugo Version: 0.124.1

Instead of fetching the de language, it fetch the translation from de-de.yaml

We have translated our pages using Translation by filename and the same issue occurs while translating the page using Translation by content directory

I have given the higher weightage for de over de-de by using weight, though it fetch de-de which has lower weightage.

This is easy to reproduce with v0.76.0 and later, where we switched nicksnyder/go-i18n v1 to nicksnyder/go-i18n v2.

git clone --single-branch -b hugo-forum-topic-52346 https://github.com/jmooring/hugo-testing hugo-forum-topic-52346
cd hugo-forum-topic-52346
hugo server

This is a known bug.
See https://github.com/gohugoio/hugo/issues/7982.

Here’s a workaround:

i18n/
β”œβ”€β”€ de.toml
β”œβ”€β”€ de_DE.toml (or de_de.toml)
└── en.toml

In your site configuration language keys, always use a hyphen to separate language from region. Both language are region are case-insensitive.

In the i18n file name, if the format is TOML or YAML, use an underscore to separate language from region. The file base name is case-insensitive. The file extension is case-sensitive.

In the i18n file name, if the format is JSON, use a hyphen or an underscore to separate language from region. The file base name is case-insensitive. The file extension is case-sensitive.

1 Like

After using this, problem has solved.Thank you for your guidance.

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