UNPKG

react-i18next

Version:

Internationalization for react done right. Using the i18next i18n ecosystem.

20 lines (16 loc) 444 B
import React from 'react'; import { useTranslation } from './useTranslation'; export function withTranslation(ns) { return function Extend(WrappedComponent) { function I18nextWithTranslation(props) { const [t, i18n, ready] = useTranslation(ns, props); return React.createElement(WrappedComponent, { ...props, t, i18n, tReady: ready, }); } return I18nextWithTranslation; }; }