此代码来自recat-admin 演示 i18n翻译,
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'我从来没有遇到过这样的代码
谢谢您:)
发布于 2021-05-25 12:46:48
react-admin使用多角化作为其默认的i18n提供程序。这就是如何定义消息的单数和复数形式:
name: 'Singular |||| Plural'
在某些语言中,您可能需要两个以上的变体:
name: 'WhenZero |||| WhenOne |||| WhenMoreThanOne'
在react中,您可以调用useTranslate钩子来获得一个translate函数。该函数接受两个参数:
如果您阅读了polyglot文档,您将看到在第二个参数中可以传递一个特殊的变量,名为smart_count。此变量由polyglot使用,用于返回消息的正确多元化形式。
get管理员使用这个特性来获得正确的标题。在资源名称的情况下,我们显示列表页和菜单项的多元版本,以及用于创建、编辑和显示的单数版本。
https://stackoverflow.com/questions/67667353
复制相似问题