HUGO

I118n and variables

Hi,

i don’t find anything in the doc about using variables in 118n function.

my yaml file:

 - id: need_register
  translation: "Registration needed for {{ .Params.variable }}"

in my partial

{{ i18n "need_register" }}

This is returning

Any help ?

Thank you.

You need to pass the context to the i18n function.

{{ i18n "need_register" . }}

. being your page here.

See this blog post

What if i’m in a short code ? How can i pass the page context ? i got can’t evaluate field variable in type interface {}

Your shortcode has your page context in .Page.

{{ i18n "need_register" .Page }}
1 Like

Thank you very much ! I actually found your blog posts on google, they are really usefull. Merci !

1 Like

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