@m6web/react-i18n
Advanced tools
Comparing version 1.7.0 to 1.8.0
@@ -5,3 +5,13 @@ import { useContext } from 'react'; | ||
export var useTranslate = function useTranslate() { | ||
return useContext(Context); | ||
var t = useContext(Context); | ||
return function (key) { | ||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
data = _ref.data, | ||
number = _ref.number, | ||
general = _ref.general, | ||
renderers = _ref.renderers; | ||
return t(key, data, number, general, renderers); | ||
}; | ||
}; |
@@ -13,3 +13,13 @@ 'use strict'; | ||
var useTranslate = exports.useTranslate = function useTranslate() { | ||
return (0, _react.useContext)(_i18n.Context); | ||
var t = (0, _react.useContext)(_i18n.Context); | ||
return function (key) { | ||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
data = _ref.data, | ||
number = _ref.number, | ||
general = _ref.general, | ||
renderers = _ref.renderers; | ||
return t(key, data, number, general, renderers); | ||
}; | ||
}; |
{ | ||
"name": "@m6web/react-i18n", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"description": "Provider and utils for translation in a react app", | ||
@@ -53,3 +53,4 @@ "main": "lib/index.js", | ||
"release": "yarn lint && yarn test && yarn build && yarn version" | ||
} | ||
}, | ||
"gitHead": "b2ec63de8741d9a6dae02580749f37b269fc2121" | ||
} |
@@ -154,3 +154,3 @@ # React i18n for 6play apps | ||
export const MyComponent = ({ nbExample }) => { | ||
export const MyComponent = ({ number }) => { | ||
const t = useTranslate(); | ||
@@ -160,8 +160,4 @@ | ||
<div class="foo"> | ||
<h1> | ||
{t('foo.bar')} | ||
</h1> | ||
<p> | ||
{t('foo.exemple', data, nbExample, true)} | ||
</p> | ||
<h1>{t('foo.bar')}</h1> | ||
<p>{t('foo.exemple', { data, number, general: true })}</p> | ||
</div> | ||
@@ -232,3 +228,3 @@ ); | ||
<div class="foo"> | ||
<p>{t('foo.example', undefined, undefined, undefined, renderers)}</p> | ||
<p>{t('foo.example', { renderers })}</p> | ||
</div> | ||
@@ -235,0 +231,0 @@ ); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33331
635
243