Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 名称是什么:';XXX | | | | XXXs';,在i18n中是什么意思?_Typescript_React Admin_React I18next - Fatal编程技术网

Typescript 名称是什么:';XXX | | | | XXXs';,在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',

此代码来自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'
我从来没有遇到过这样的代码||||

谢谢:)

react admin将其用作默认的i18n提供程序。以下是您如何定义消息的单数和复数形式:

name:“单数| | | |复数”

在某些语言中,您可能需要两种以上的变体:

name:'WhenZero | | | | | | | | | | | | WhenMoreThanOne'

在react admin中,您可以调用
useTranslate
hook来获得
translate
函数。此函数接受2个参数:

  • 翻译键
  • 要在翻译的消息中插入的变量对象
如果您阅读polyglot文档,您将看到可以在第二个参数中传递一个特殊变量,称为
smart\u count
。polyglot使用此变量返回消息的正确复数形式


react admin使用此功能获取正确的标题。对于资源名称,我们显示列表页面和菜单项的复数版本,以及用于创建、编辑和显示的单数版本。

react admin i18n使用polyglot,这是polyglotjs的模板语句。非常感谢。好的,我明白。但是它怎么知道什么时候用在什么地方呢?我补充了更多的细节