更改模板中的日期区域设置 Keystone.js

change date locale in template Keystone.js

我使用 keystone.js 和 twig.js 作为模板语言。我如何更改日期的语言环境? http://keystonejs.com/docs/database/#fieldtypes-date 我查看了所有问题和 Whosebug 问题,但没有找到答案。在我的模板中我写 {{ post._.publishedDate.format('D MMMM') }} 输出为 9 July。我希望它在俄语语言环境中是 9 июля。 据我所知,KeystoneJS 使用 moment.js 来设置日期格式。但是我怎样才能改变 momentjs 语言环境?我应该在我的模板或 keystone.js 或中间件或 keystone.js 文件中的某处执行此操作吗?

我试过这个:

{{ post._.publishedDate.locale('ru').format('D MMMM') }}
{{ post.publishedDate.locale('ru').format('D MMMM') }}
{{ post._.publishedDate.format('D MMMM', 'ru') }}
{{ post._.publishedDate.format('D MMMM', 'ru') }}
{{ post.publishedDate.parse('Do MMM YYYY') }}
{{ _.format(post.publishedDate, 'D MMM') }}

我还尝试在 keystone.js 文件中设置局部变量 moment = require('moment') 然后在模板中

{{ moment(post.publishedDate).locale('ru').format('D MMMM') }}

它也没有用。我做错了什么?

我不明白 KeystoneJS 如何与 momentjss 一起工作,我该怎么办。 this documentation part 不是很有帮助。

我认为您可以将整个网站的默认语言设置为。

// keystone.js
var moment = require('moment');
moment.locale(locale);