Hugo,如何设置日期语言
我正在与 Hugo 一起创建一个法语博客。 目前我的所有日期都以英语显示(二月),但我希望它们以法语显示(février)。 如何设置语言?
我的 config.toml 看起来像这样:
baseURL = 'http://example.org/'
languageCode = 'fr-FR'
defaultContentLanguage = "fr"
defaultContentLang = "fr"
title = 'TITLE'
theme = "THEME"
我尝试将 languageCode、defaultContentLanguage 和 defaultContentLang 设置为 fr 但没有成功。
我不需要多语言支持,我只需要法语。
With Hugo, I'm creating a blog in french.
Currently all my date are displayed in english (february) but I want them to be displayed in french (février).
How to set the language ?
My config.toml
looks like this:
baseURL = 'http://example.org/'
languageCode = 'fr-FR'
defaultContentLanguage = "fr"
defaultContentLang = "fr"
title = 'TITLE'
theme = "THEME"
I try to set languageCode
, defaultContentLanguage
and defaultContentLang
to fr
but with no success.
I don't need multi language support, I just only need french.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要使用本地化,您需要使用 Hugo 函数
time.Format
(它有一个别名dateFormat
)。它需要两个参数:示例:
{{ time.Format "Jan. 2, 2006" .Date }}
或
{{ dateFormat "Jan. 2 , 2006" .Date }}
文档:https://gohugo.io/functions/dateformat/
.Format
方法(例如{{.Date.Format "Jan. 2, 2006 }}
)将不会应用所需的本地化。To use localization, you need to use the Hugo function
time.Format
(which has an aliasdateFormat
). It takes two parameters:Example:
{{ time.Format "Jan. 2, 2006" .Date }}
or
{{ dateFormat "Jan. 2, 2006" .Date }}
Docs: https://gohugo.io/functions/dateformat/
The
.Format
method (e.g.{{.Date.Format "Jan. 2, 2006}}
) will not apply the desired localization.