# Possible undocumented i18n feature. Worth updating the docs?

**URL:** <https://discourse.gohugo.io/t/possible-undocumented-i18n-feature-worth-updating-the-docs/33235>\
**Category:** Meta\
**Tags:** i18n\
**Created:** [June 4, 2021, 8:05pm UTC](https://discourse.gohugo.io/t/possible-undocumented-i18n-feature-worth-updating-the-docs/33235 "2021-06-04T20:05:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LandGod](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/landgod/32/12321_2.png) [@LandGod](https://discourse.gohugo.io/u/LandGod)\
**Post date:** [June 4, 2021, 8:05pm UTC](https://discourse.gohugo.io/t/possible-undocumented-i18n-feature-worth-updating-the-docs/33235/1 "2021-06-04T20:05:33Z")

</div>

I noticed an interesting thing that another dev who works on the same website as me dropped into our code. I initially assumed it must be junk since it’s not mentioned at all in the docs, but after seeing that it worked I actually think it’s an undocumented feature of the `i18n` function.

I was thinking of making a PR to the Hugo Docs to add info about it to the `i18n` article, but after reading about what sorts of PRs are accepted, I’m a bit unsure if this is the kind of thing that _should_ be documented, or if it would be considered “not a best practice” and therefore should remain undocumented.

The feature is the ability to put Hugo tags within `i18n` entries and then pass a dictionary of replacement text as the second argument to `i18n`. Here is the working example from our code base to demonstrate:

Simplified version of our code as it appears in the template partial:

```auto
<img alt="{{- ( i18n "name_talks_about_gh_accelerator" (dict "Name" .slide.alt)) -}}">

```

Relevant entry in translation file:

```auto
[name_talks_about_gh_accelerator]
other = "{{ .Name }} talks about the GH Accelerator"

```

And on the site I can see that the text outputted to our HTML is inserting the value of `.slide.alt` in place of `{{ .Name }}` in the translated text. EG (if `.slide.alt === “Bob Johnson”):

```auto
<img alt="Bob Johnson talks about the GH Accelerator">

```

Please let me know what y’all think about this.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [June 4, 2021, 8:44pm UTC](https://discourse.gohugo.io/t/possible-undocumented-i18n-feature-worth-updating-the-docs/33235/2 "2021-06-04T20:44:55Z")

</div>

> [@LandGod](#):
>
> Please let me know what y’all think about this.

I’m surprised that isn’t in the docs.

- You can pass any data as the second argument to `i18n`
- If what you pass is a number, then we also use that to determine the `plural` state (0, 1, many)
- If it’s a map/struct, we also look for a `.Count`/`.count` field/entry to determine the `plural` state

---

<div class="post-metadata">

**Author:** ![LandGod](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/landgod/32/12321_2.png) [@LandGod](https://discourse.gohugo.io/u/LandGod)\
**Post date:** [June 4, 2021, 8:46pm UTC](https://discourse.gohugo.io/t/possible-undocumented-i18n-feature-worth-updating-the-docs/33235/3 "2021-06-04T20:46:11Z")

</div>

Thanks! I’ll go ahead and see about making a PR to add this info.

Edit: Upon further research I eventually discovered that this functionality is documented. However, it’s buried deep in the multi language article, where most people looking for a reference about how the specific i18n function works wouldn’t find it. So I’m still going to make a PR to add that info to the function reference article.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [June 6, 2021, 8:46pm UTC](https://discourse.gohugo.io/t/possible-undocumented-i18n-feature-worth-updating-the-docs/33235/4 "2021-06-06T20:46:43Z")

</div>

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