Since v0.87.0, Hugo brings a new feature of localizing time and dates. I gave it a shot, but it seems that need to keep the language key to be equaled to the locale name.
So I’m wondering whether is it possible to make language key to be differenced with locale name?
In order to localize time, customize the key of language which appear in the URL(zh-cn, zh-tw).
Details:
languags.toml
[zh-cn]
languageName = "简体中文"
weight = 4
contentDir = "content/zh-cn"
[zh-hans]
languageName = "zh-hans"
weight = 4
contentDir = "content/zh-hans"
[zh_hans]
languageName = "zh_hans"
weight = 4
contentDir = "content/zh_hans"
The zh_hans works as excepted, the rest of languages are not working.
partial:
{{ .Date | time.Format ":date_full" }}
I also take a close look at the source code, Hugo uses the language key for getting a translator and locale, but I’m not sure that.