1.1.0 • Published 5 years ago

slim-i18n v1.1.0

Weekly downloads
4
License
WTFPL
Repository
github
Last release
5 years ago

Slim React i18n

Slim wrapper for i18n in React with flexible utils which can be used with any i18n library.

Install

npm install slim-i18n
// or
yarn add slim-i18n

Usage

// init
import { TranslationsProvider } from 'slim-i18n';
import getTranslationAdapter from './get-translation-adapter';
import App from './app';

const i18n = getTranslationAdapter();

ReactDOM.render(
    <TranslationsProvider value={i18n}>
        <App />
    </TranslationsProvider>,
    document.getElementById('my-app')
);
// with hook
import { useI18n } from 'slim-i18n';

export default function App() {
    const i18n = useI18n();

    return (
        <div>{i18n.gettext('Hello World! I can be multi language!')}</div>
    );
}
// with HOC
import { withTranslations } from 'slim-i18n';

export default withTranslations(({ i18n }) => (
    <div>{i18n.gettext('Hello World! I can be multi language!')}</div>
));
// with Translation component
import { Translation } from 'slim-i18n';

export default function App() {
    return (
        <Translation>
            {({ i18n }) => (
                <div>{i18n.gettext('Hello World! I can be multi language!')}</div>
            )}
        </Translation>
    );
}
1.1.0

5 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago