sibelius / ast-i18n

Easily migrate your existing React codebase to use i18n
MIT License
216 stars 18 forks source link

withTranslation codemod #22

Closed sibelius closed 5 years ago

sibelius commented 5 years ago
import { withTranslation } from 'react-i18next';

export default withTranslation()(MyComponent);

Example

before:

import React from 'react';

const Simple = () => (
  <span>My simple text</span>
);

after

import React from 'react';
import { withTranslation } from 'react-i18next';

const Simple = ({ t } ) => (
  <span>{t('my_simple_text')}</span>
);

export default withTranslation()(Simple);
sibelius commented 5 years ago

I think we are good enough for now