0

我正在尝试使用翻译您自己的组件的示例

所以我这样做app.js

const messages = {
    en: {
        myroot: {
            hello: {
                world: 'Hello, World!',
            },
        },
    },
};
const App = () => (
  <Admin message={messages} locale="en" ...>
    <Resource name="myresource" edit={EditPage} />

在我的Translation组件中:

import React from 'react';
import { translate } from 'admin-on-rest';

const Translation = ({ translate }) => (
    <button>{translate('myroot.hello.world')}</button>
);

export default translate(Translation);

最后在我的EditPage

import Translation from 'path/to/Translation';

export const EditPage = (props) => (
  <Edit {...props}>
    <Translation />
  </Edit>
);

它不适合我。它只是显示myroot.hello.world在按钮中。

你能帮我解决这个问题吗?

4

1 回答 1

1

错字?

<Admin messages={messages} locale="en" ...>

请注意,道具是messages而不是message

于 2017-05-10T14:44:49.843 回答