Arif
February 12, 2024, 2:07pm
1
I tried this format but I got the error below for keys using other
failed to load translations: expected value for key "test-key" be a string but got map[string]interface
menu = "Menu"
[test-key]
other = "Test Key"
hugo v0.123.0-DEV+extended windows/amd64 BuildDate=unknown
I am unable to reproduce the problem with the provided example. What else is in the file?
Perhaps you using one of the reserved key names as discussed here:
https://discourse.gohugo.io/t/what-keys-can-be-passed-to-i18n-files/48243
On an unrelated note, avoid using anything but letters, numbers, and underscores in key names. It’s a good habit, allowing you to do things like my.dot_chained.identifier
. That wouldn’t work with a hyphen.
https://gohugo.io/getting-started/glossary/#identifier
Arif
February 12, 2024, 4:47pm
3
description
was the culprit. Was using it to translate site description
jmooring:
and underscores
I am not a fan of underscores in file or key names. But in this case, I will follow your advice.
In the data directory, you must use underscores because this fails:
{{ site.Data.some-file.foo }}
Arif
February 12, 2024, 5:42pm
5
I am aware of data files coz I encountered the same issue months back. I went with numbers instead.
system
Closed
February 14, 2024, 5:43pm
6
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.