Strange printI18nWarning WARN

My site has 4 languages, works perfectly, I have all translations fine and lang logic is perfect.
It relies on:

Before going to production, I decided to double check doing `hugo hugo --cleanDestinationDir --printI18nWarnings`.
And surprisingly I get a lot of WARN.
It seems there are of 2 sorts:

  • Some looks like a variable (search_no_result). I do not have this variable on web part or themes folder (I do have some external modules loaded)

  • and all FM variable named `meta_title`. Looks like all of them are reported as WARN. But all those FM `meta_title` have values.

    ```text
    WARN i18n|MISSING_TRANSLATION|fr|search_no_results
    WARN i18n|MISSING_TRANSLATION|en|search_no_results
    WARN i18n|MISSING_TRANSLATION|de|search_no_results
    WARN i18n|MISSING_TRANSLATION|it|search_no_results

    WARN i18n|MISSING_TRANSLATION|fr|pour nous contacter
    ou juste nous dire bonjour !
    WARN i18n|MISSING_TRANSLATION|en|contact us
    or simply say hello!
    WARN i18n|MISSING_TRANSLATION|de|kontaktieren sie uns
    oder sagen sie einfach hallo!
    WARN i18n|MISSING_TRANSLATION|it|contattateci
    o semplicemente venite a salutarci!

    WARN i18n|MISSING_TRANSLATION|fr|cuisine 100% authentique
    WARN i18n|MISSING_TRANSLATION|en|100% authentic cuisine
    WARN i18n|MISSING_TRANSLATION|de|100% authentische küche
    WARN i18n|MISSING_TRANSLATION|it|cucina 100% autentica

    and so on.
    ```

If i understand that the external modules can be the cause for variable `search_no_results`, even if i am not using it at the mloment in my code (I will investigate this one), I am really puzzled by the warning on my FM variable.

The template calling `meta_title` is something simple:

` {{ partial “page-header” (dict “Context” . “Title” .Params.meta_title ) }}`

and page header is also a simple one:

{{ $context := .Context }}

<h1>
  {{ i18n (printf "%s" (lower $context.Title)) | default $context.Title | title | markdownify }}
</h1>

  {{ i18n "nb_people" }}

  {{ i18n "people_from" }}

  {{ i18n "people_to" }}

  {{ $context.Description | markdownify }}

I get the same errors even if I replace the H1 by

{{ $context.Title | markdownify }}

```

1) WARN i18n|MISSING_TRANSLATION|fr|search_no_results

check your themes data files - looks like there’s something missing or a typo or a typo.

2) Your frontmatter looks like a context problem:

within your partial the DOT is the dict passed, so we have:

  • .Context = whatever your dot was in the caller (supposedly the Page)
  • .Title = the value of .Params.meta_title from the caller

your partial assigns {{ $context := .Context }} → your Page from above

So here {{ i18n (printf "%s" (lower $context.Title)) you refer to the Page Title, not your dicts Title and lookup that one instead of the meta_title

call i18n on .Title within the partial

overall, if that is the complete template, passing the page will also pass the params.

{{ partial "page-header" . }}

and in your partial
  {{ $context := . }}
  <h1>
    {{ i18n (printf "%s" (lower $context.Params.meta_title)) | default $context.Title | title | markdownify }}
  </h1>
  {{ i18n "nb_people" }}
  {{ i18n "people_from" }}
  {{ i18n "people_to" }}
  {{ $context.Description | markdownify }}

If you need to pass separately:

  • I would not rename the parameter to Title - you will always get puzzled about the value, (meta or not?)
    I would leave it as is meta_title or if you need to rename MetaTitle

mmh. maybe another place where that is passed to i18n. hard to tell

Hello, and thanks a lot for your review. You point me in the right direction.

Deep in the theme I used as base before modifying it there was a “silent” call for i18n on some `$context.Title` but $context was different, and value was empty. Hence the i18n.

Thanks for this.