如何添加 moment.locale()

Wen*_*non 0 javascript momentjs react-native

我有一个用英语进行的约会时刻。我正在尝试添加moment.locale法语约会,但它不起作用。应该创建一个变量来做到这一点?或者只是添加moment.locale()某个地方?

 <View style={{flex: 1}}>
        <Text style={{color: 'white', textAlign: 'center', marginTop:20}}>
              
              {moment(element.dateMatch).format('LLLL')}
            </Text>
        </View>
Run Code Online (Sandbox Code Playgroud)

使用此代码我可以得到英文日期。

Tho*_*mas 5

这是我在文件顶部初始化区域设置的内容

import moment from 'moment';
import 'moment/locale/fr';
import 'moment/locale/nl';
Run Code Online (Sandbox Code Playgroud)

应明确包含每种受支持的语言,因为反应本机包是完全预先构建的。

再进一步,可以通过将语言环境设置为 fr (或任何其他导入的语言环境)来激活语言环境:

moment.locale('fr');
Run Code Online (Sandbox Code Playgroud)