我想用moment库把日期翻译成法语。
我创建了一个android构建,但当我打开组件时,它崩溃了。
我的代码是:
import Moment from 'moment';
// i fixed the error
// var moment = require('moment');
//require('moment/locale/fr');
//moment.locale('fr');
render() {
....
{
this.state.notifications.map((notification, i) => (
Moment.updateLocale('fr', {
// the config here
// translate to french
}),
notification.type === 'Partage de contact' ?
<ListItem
key={i}
...
subtitle={`Date : ${Moment(notification.date).format('dddd D MMMM, YYYY')}`}
bottomDivider
/>
:
<ListItem
...
subtitle={`Date : ${Moment(notification.date).format('dddd D MMMM, YYYY')}`}
bottomDivider
/>
))
}
...
}发布于 2020-01-29 21:47:58
使用moment.local()将日期转换为任何(法语)语言
import moment from 'moment';
render() {
var march = moment('2017-03')
console.log(march.format('MMMM'))
moment.locale('fr') // you can set here
console.log(march.format('MMMM'))
................
}https://stackoverflow.com/questions/59968152
复制相似问题