uni*_*e11 14 i18next reactjs react-native
我想翻译我的颜色,但不知道该怎么做。
const Item = memo(({ color, index, lastIndex, translateName, style, activeColor, onPress }: IColorItem) => {
return (
<Text>{translateName}</Text>
)
// @ts-ignore
}, isEq);
const Colors = ({ colors, style, activeColor, onPress }: IColors) => {
const { t } = useTranslation();
const renderItem: ListRenderItem<ColorsType> = ({ item, index }) => (
<Item
color={item}
translateName={t('colors.color', { color: item })}
index={index}
style={style}
activeColor={activeColor}
lastIndex={colors.length - 1}
onPress={onPress}
/>
)
return (
<View style={s.container}>
<FlatList
data={colors as ColorsType[]}
renderItem={renderItem}
style={s.flatList}
keyExtractor={(item, i) => i.toString()}
horizontal
showsHorizontalScrollIndicator={false}
/>
</View>
)
}
Run Code Online (Sandbox Code Playgroud)
翻译.json
"colors": {
"color": "{{color, COLORS}}"
},
Run Code Online (Sandbox Code Playgroud)
什么都不起作用。我怎么说“红色”=...,“蓝色”=...?
...................................................... ...................................................... ………………………………
小智 31
您可以在 i18n 文档中看到插值:https ://www.i18next.com/translation-function/interpolation
{
"key": "{{what}} is {{how}}"
}
i18next.t('key', { what: 'i18next', how: 'great' });
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
16713 次 |
最近记录: |