UNPKG

@kiwicom/orbit-components

Version:

Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.

20 lines (18 loc) 701 B
import _extends from "@babel/runtime/helpers/esm/extends"; import * as React from "react"; import { pureTranslate } from "../Translate"; import DictionaryContext from "./DictionaryContext"; const Dictionary = ({ values, children }) => /*#__PURE__*/React.createElement(DictionaryContext.Provider, { value: values }, children); export function withDictionary(Component) { return function DictionaryComponent(props) { return /*#__PURE__*/React.createElement(DictionaryContext.Consumer, null, dictionary => /*#__PURE__*/React.createElement(Component, _extends({}, props, { translate: (tKey, values) => pureTranslate(dictionary, tKey, values) }))); }; } export default Dictionary;