Closed pumpkinduan closed 2 years ago
All of the .d
or .defaultMessage
is required for extracting message.
intl.get('common.special').d('special')
are you saying the .d is compulsory for all .get()?
intl.get('common.special').d('special')
are you saying the .d is compulsory for all .get()?
Yes, it is.
操作流程与业务代码
const Component = () => { const header = useMemo(() => { return { title: !isSelectedCustomMode() ? intl.get('meet_room.room_booking.circle_tip') : intl.get('meet_room.room_booking.simple_repeat_type_custom').d('Custom'), left: ,
right: (
}
但由于不兼容intl.get('key')的写法,必须写intl.get('key').d('value'),脚本才会正常提取文案,原因是如下代码:
所以为了兼容原来的写法:intl.get('key'),校验message没有默认值时的错误处理,我暂时关闭了, 且过滤掉了没有默认值的message,如下图:
然后 执行 react-intl-universal-extract --cmd extract --source-path ./src --output-path ./locales/cn.json
最后生成出来的json文件,部分key值与value对应不上,如下:
疑问???我打印了extractMessage执行时,正则匹配的结果,如下:
我想,match[3]应该为'meet_room.room_booking.simple_repeat_type_workday'这个key才对,但实际却是‘meet_room.room_booking.simple_repeat_type_never’ 是这个匹配的正则出了问题,还是这个工具的机制是这样呢?