# Multilingual Shortcode Recommendation

**URL:** <https://discourse.gohugo.io/t/multilingual-shortcode-recommendation/17264>\
**Category:** support\
**Created:** [February 27, 2019, 5:33pm UTC](https://discourse.gohugo.io/t/multilingual-shortcode-recommendation/17264 "2019-02-27T17:33:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![brettf](https://avatars.discourse-cdn.com/v4/letter/b/c0e974/32.png) [@brettf](https://discourse.gohugo.io/u/brettf)\
**Post date:** [February 27, 2019, 5:33pm UTC](https://discourse.gohugo.io/t/multilingual-shortcode-recommendation/17264/1 "2019-02-27T17:33:34Z")

</div>

If I have a shortcode `{{ < synopsis-foo > }}` that exists in the `/layouts/shortcodes` directory that I include in multiple places across my `en-us` content, what is the recommended approach when I want to translate that shortcode and include it across content in my `zh-cn` content folder?

Here is the actual [repo](https://github.com/aws/iot-atlas/tree/master/layouts/shortcodes) where I have my shortcodes.

---

<div class="post-metadata">

**Author:** ![brettf](https://avatars.discourse-cdn.com/v4/letter/b/c0e974/32.png) [@brettf](https://discourse.gohugo.io/u/brettf)\
**Post date:** [March 1, 2019, 8:16pm UTC](https://discourse.gohugo.io/t/multilingual-shortcode-recommendation/17264/2 "2019-03-01T20:16:08Z")

</div>

For further detail… I have tried simply adding a `zh` variant:

```auto
/layouts/shortcodes/shortcode-foo.html
/layouts/shortcodes/shortcode-foo.zh.html

```

…and although the `hugo server` shows that it detects and builds the file which includes the `zh` text, that `zh` text is **not** included when `shortcode-foo` is referenced elsewhere in the `zh` site.

---

<div class="post-metadata">

**Author:** ![brettf](https://avatars.discourse-cdn.com/v4/letter/b/c0e974/32.png) [@brettf](https://discourse.gohugo.io/u/brettf)\
**Post date:** [April 3, 2019, 6:48pm UTC](https://discourse.gohugo.io/t/multilingual-shortcode-recommendation/17264/3 "2019-04-03T18:48:24Z")

</div>

I am still seeking input on this. I have a hack wherein we simply included copies of the content outside of the short-codes, but I’d rather have in in a single place instead of having multiple copies.

---

<div class="post-metadata">

**Author:** ![kascme](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kascme/32/6816_2.png) [@kascme](https://discourse.gohugo.io/u/kascme)\
**Post date:** [April 3, 2019, 7:24pm UTC](https://discourse.gohugo.io/t/multilingual-shortcode-recommendation/17264/4 "2019-04-03T19:24:02Z")

</div>

Now why do your shortcodes have a HTML and body tag? They are supposed to be placed within the contents’ HTML.

Anyway. Have a look at the [transition of strings](https://gohugo.io/content-management/multilingual/#translation-of-strings). So you make one shortcode synapsis and call it together with an argument `{{% synapsis "Foo" %}}`. Within that shortcode you get your translated text with `{{ T (.Get 0) }}`. Another probability is to store it as [data](https://gohugo.io/templates/data-templates/) and than call that data from the shortcode

---

<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:** [April 3, 2019, 8:38pm UTC](https://discourse.gohugo.io/t/multilingual-shortcode-recommendation/17264/5 "2019-04-03T20:38:16Z")

</div>

The above should just work.
