Timeago.js 使用语言环境配置
Timeago.js use locale configs
我正在使用 timeago.js 将存储在数据库中的信息显示为“...小时前”。
我的问题是我需要将它翻译成 pt_BR,我在文档上看到他们有这个选项并尝试在我的 ReactJS 代码上实现它但我没有得到任何东西,它仍然是英文的。
import { format } from 'timeago.js'
export default function Post({post}) {
...
<span className="postDate">{format(post.createdAt, 'pt_BR')}</span>
...
只是想知道,我正在使用 MongoDB。
我的错误在哪里?
我知道怎么做了:
import * as timeago from 'timeago.js'
import TimeAgo from 'timeago-react'
import pt_BR from 'timeago.js/lib/lang/pt_BR'
timeago.register('pt_BR', pt_BR)
<span className="postDate">
<TimeAgo datetime={post.createdAt} locale='pt_BR' />
</span>
我正在使用 timeago.js 将存储在数据库中的信息显示为“...小时前”。 我的问题是我需要将它翻译成 pt_BR,我在文档上看到他们有这个选项并尝试在我的 ReactJS 代码上实现它但我没有得到任何东西,它仍然是英文的。
import { format } from 'timeago.js'
export default function Post({post}) {
...
<span className="postDate">{format(post.createdAt, 'pt_BR')}</span>
...
只是想知道,我正在使用 MongoDB。
我的错误在哪里?
我知道怎么做了:
import * as timeago from 'timeago.js'
import TimeAgo from 'timeago-react'
import pt_BR from 'timeago.js/lib/lang/pt_BR'
timeago.register('pt_BR', pt_BR)
<span className="postDate">
<TimeAgo datetime={post.createdAt} locale='pt_BR' />
</span>