redux-polyglot
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -53,4 +53,3 @@ 'use strict'; | ||
var getPolyglotOptions = function getPolyglotOptions(state, _ref2) { | ||
var _ref2$polyglotOptions = _ref2.polyglotOptions, | ||
polyglotOptions = _ref2$polyglotOptions === undefined ? {} : _ref2$polyglotOptions; | ||
var polyglotOptions = _ref2.polyglotOptions; | ||
return polyglotOptions; | ||
@@ -76,27 +75,24 @@ }; | ||
var getTranslationMorphed = function getTranslationMorphed() { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
var getTranslationMorphed = (0, _reselect.createSelector)(getTranslation, function (t) { | ||
return function (f) { | ||
return (0, _redux.compose)(f, getTranslation.apply(undefined, args)); | ||
return (0, _redux.compose)(f, t); | ||
}; | ||
}; | ||
var getTranslationUpperCased = function getTranslationUpperCased() { | ||
return getTranslationMorphed.apply(undefined, arguments)(toUpper); | ||
}; | ||
var getTranslationCapitalized = function getTranslationCapitalized() { | ||
return getTranslationMorphed.apply(undefined, arguments)(capitalize); | ||
}; | ||
var getTranslationTitleized = function getTranslationTitleized() { | ||
return getTranslationMorphed.apply(undefined, arguments)(titleize); | ||
}; | ||
}); | ||
var getTranslationUpperCased = (0, _reselect.createSelector)(getTranslationMorphed, function (m) { | ||
return m(toUpper); | ||
}); | ||
var getTranslationCapitalized = (0, _reselect.createSelector)(getTranslationMorphed, function (m) { | ||
return m(capitalize); | ||
}); | ||
var getTranslationTitleized = (0, _reselect.createSelector)(getTranslationMorphed, function (m) { | ||
return m(titleize); | ||
}); | ||
var createGetP = function createGetP(polyglotOptions) { | ||
return function (state) { | ||
var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
polyglotScope = _ref3.polyglotScope; | ||
if (!getLocale(state) || !getPhrases(state)) { | ||
var options = { polyglotOptions: polyglotOptions }; | ||
var getP = (0, _reselect.createSelector)(getLocale, getPhrases, getPolyglot, getTranslation, getTranslationCapitalized, getTranslationTitleized, getTranslationUpperCased, getTranslationMorphed, function (locale, phrases, p, t, tc, tt, tu, tm) { | ||
if (!locale || !phrases) { | ||
return { | ||
@@ -110,10 +106,12 @@ t: _utils.identity, | ||
} | ||
var options = { polyglotScope: polyglotScope, polyglotOptions: polyglotOptions }; | ||
return _extends({}, getPolyglot(state, options), { | ||
t: getTranslation(state, options), | ||
tc: getTranslationCapitalized(state, options), | ||
tt: getTranslationTitleized(state, options), | ||
tu: getTranslationUpperCased(state, options), | ||
tm: getTranslationMorphed(state, options) | ||
return _extends({}, p, { | ||
t: t, | ||
tc: tc, | ||
tt: tt, | ||
tu: tu, | ||
tm: tm | ||
}); | ||
}); | ||
return function (state, props) { | ||
return getP(state, _extends({}, props, options)); | ||
}; | ||
@@ -120,0 +118,0 @@ }; |
@@ -38,3 +38,3 @@ 'use strict'; | ||
var translate = function translate(fstArg, sndArg) { | ||
if ((0, _utils.isFunction)(fstArg)) return translateEnhancer('', fstArg);else if ((0, _utils.isString)(fstArg) && sndArg === undefined) return translateEnhancer(fstArg); | ||
if (fstArg === undefined && sndArg === undefined) return translateEnhancer('');else if ((0, _utils.isFunction)(fstArg)) return translateEnhancer('', fstArg);else if ((0, _utils.isString)(fstArg) && sndArg === undefined) return translateEnhancer(fstArg); | ||
return translateEnhancer(fstArg, sndArg); | ||
@@ -41,0 +41,0 @@ }; |
{ | ||
"name": "redux-polyglot", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Tool for using Polyglot.js with Redux", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -141,2 +141,3 @@ # redux-polyglot | ||
translate('catalog', Dummy); // with polyglotScope | ||
translate()(Dummy); // curried | ||
translate('catalog')(Dummy); // curried with polyglotScope. | ||
@@ -143,0 +144,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
171
20420
283