Pass multiple variables to i18n function

This is about Translation of strings.

From go-i18n repository examples:

"person_unread_email_count_timeframe": {
    "one":  "{{.Person}} has {{.Count}} unread email in the past {{.Timeframe}}.",
    "other":  "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."

Multiple variables is used here. But in Hugo, only .Count is available. I couldn’t find any way to pass multiple variables to i18n function. And whatever variable I pass, it is assigned to .Count (even if it’s a string, not a number).

Is there any way to pass multiple variable to i18n function?

1 Like

Use dict:


I know this is an old post, but it’s the only one that addresses exactly a search for “hugo i18n Count many parameters”. I think the following info could help others.

Use dict:

Yes, thanks! Specifically for this question, the dict to pass would be:

{{ i18n "yourkeyfori18nfile" (dict "Person" .Params.person "Timeframe" .Params.timeframe "Count" .Paramwithanumber ) }}

where the Params could be variables or whatever. This was confusing to me for a while because I thought I had to also pass the “.” scope in there somewhere.


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