【问题标题】:translate example is not working翻译示例不起作用
【发布时间】:2017-05-10 22:44:49
【问题描述】:

我正在尝试使用translating your own component的例子

所以我在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

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

【问题讨论】:

    标签: admin-on-rest


    【解决方案1】:

    错别字?

    &lt;Admin messages={messages} locale="en" ...&gt;

    注意,prop 是 messages 而不是 message

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-09
      • 2015-06-23
      • 2014-04-20
      • 1970-01-01
      • 1970-01-01
      • 2017-10-30
      • 2018-09-06
      相关资源
      最近更新 更多