Typescript 名称是什么:';XXX | | | | XXXs';,在i18n中是什么意思?
此代码来自recat admin i18n翻译Typescript 名称是什么:';XXX | | | | XXXs';,在i18n中是什么意思?,typescript,react-admin,react-i18next,Typescript,React Admin,React I18next,此代码来自recat admin i18n翻译 invoices: { name: 'Invoice |||| Invoices', fields: { date: 'Invoice date', customer_id: 'Customer', command_id: 'Order', date_gte: 'Passed Since',
invoices: {
name: 'Invoice |||| Invoices',
fields: {
date: 'Invoice date',
customer_id: 'Customer',
command_id: 'Order',
date_gte: 'Passed Since',
date_lte: 'Passed Before',
total_gte: 'Min amount',
address: 'Address',
},
},
你能解释一下这一排是什么意思吗
name: 'Invoice |||| Invoices'
我从来没有遇到过这样的代码||||
谢谢:)react admin将其用作默认的i18n提供程序。以下是您如何定义消息的单数和复数形式:
name:“单数| | | |复数”
在某些语言中,您可能需要两种以上的变体:
name:'WhenZero | | | | | | | | | | | | WhenMoreThanOne'
在react admin中,您可以调用useTranslate
hook来获得translate
函数。此函数接受2个参数:
- 翻译键
- 要在翻译的消息中插入的变量对象
smart\u count
。polyglot使用此变量返回消息的正确复数形式
react admin使用此功能获取正确的标题。对于资源名称,我们显示列表页面和菜单项的复数版本,以及用于创建、编辑和显示的单数版本。react admin i18n使用polyglot,这是polyglotjs的模板语句。非常感谢。好的,我明白。但是它怎么知道什么时候用在什么地方呢?我补充了更多的细节