0

I'm trying to use the example of translating your own component

so i'm doing this in app.js:

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

and in my Translation component:

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

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

export default translate(Translation);

finally in my EditPage:

import Translation from 'path/to/Translation';

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

its not working for me. its just showing myroot.hello.world in the button.

could you please help me out with that?

pelak
  • 70
  • 5

1 Answers1

1

Typo ?

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

Note that the prop is messages and not message

Gildas Garcia
  • 6,966
  • 3
  • 15
  • 29