UNPKG

react-translate-maker

Version:

React translation module. Internationalize your great project.

28 lines (25 loc) 665 B
import React, { useContext } from 'react'; import NamespaceContext from './NamespaceContext'; function computePath(path, compose, namespace) { if (!compose) { return path; } return namespace && compose ? `${namespace}.${path}` : path; } export default function Namespace(props) { const { path, compose, children } = props; const namespace = useContext(NamespaceContext); const currentPath = computePath(path, compose, namespace); return React.createElement(NamespaceContext.Provider, { value: currentPath }, children); } Namespace.defaultProps = { path: undefined, compose: false }; //# sourceMappingURL=Namespace.js.map